我有webpack设置和构建没有错误。正确包含了物化css,但JavaScript从未初始化,并且未正确添加字体。
我有使用其他模块加载器的经验,例如require.js,但我遗漏了一些东西。
这些是相关文件。输出目录确实包含所有重命名的字体文件,这些字体文件似乎是完全随机的。
webpack.config.js
var path = require("path");
var webpack = require("webpack");
module.exports = {
entry: ["./web/static/js/app.js"],
output: {
path: "./priv/static/",
filename: "app.js"
},
module: {
loaders: [{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},{
test: /\.css$/,
loaders: ["style", "css"]
},{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "file-loader"
}]
},
resolve: {
root: [
"./web/static/js",
"./web/static/style"
],
moduleDirectories: [
"node_modules",
"bower_components"
]
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"Hammer": "hammerjs/hammer"
}),
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
)
]
}
app.js
require('materialize-css/dist/css/materialize.min.css');
var jquery = require('exports?jQuery!jquery/dist/jquery.min.js');
var materialize = require('imports?jquery!materialize-css/dist/js/materialize.min.js');
提前感谢您的帮助