与bower一起使用时,webpack将供应商区块放到应用程序区块
webpack.config.js与bower一起使用时,webpack将供应商区块放到应用程序区块,webpack,Webpack,webpack.config.js var path = require("path"); var webpack = require("webpack"); module.exports = { entry: "./res/app/entry.js", vendor: ["jquery"], output: { path: __dirname + "/res/js/", filename: "app.js" }, modu
var path = require("path");
var webpack = require("webpack");
module.exports = {
entry: "./res/app/entry.js",
vendor: ["jquery"],
output: {
path: __dirname + "/res/js/",
filename: "app.js"
},
module: {
loaders: [
{test: /\.css$/, loader: "style!css"}
]
},
resolve: {
root: [path.join(__dirname, "bower_components")]
},
plugins: [
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
),
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js")
]
};
bower.json:
{
"name": "webapp",
"version": "0.0.0",
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"devDependencies": {
"jquery": "~1.11"
},
"resolutions": {
"jquery": "~1.11"
}
}
运行webpack
后,将生成两个文件:
app.js(the application chunk)
vendor.bundle.js(vendor chunk)
但是,jquery
放在app.js
中,它应该在vendor.bundle.js
中
有什么问题吗?我错了,
条目的格式错误,应该是:
entry: {
app: "./res/app/entry.js",
vendor: ["jquery"]
},