Do not hardcoded vendor bundles in webpack

This commit is contained in:
Pavel Djundik 2017-06-27 12:40:14 +03:00
parent 20b24a39df
commit a3744cf81b
2 changed files with 12 additions and 12 deletions

5
scripts/noop.js Normal file
View File

@ -0,0 +1,5 @@
"use strict";
module.exports = function() {
return function() {};
};

View File

@ -10,17 +10,6 @@ const path = require("path");
const config = {
entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
"js/bundle.vendor.js": [
"handlebars/runtime",
"jquery",
"jquery-textcomplete",
"jquery-ui/ui/widgets/sortable",
"moment",
"mousetrap",
"socket.io-client",
"urijs",
"fuzzy",
],
},
devtool: "source-map",
output: {
@ -71,7 +60,13 @@ const config = {
json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("js/bundle.vendor.js")
// socket.io uses debug, we don't need it
new webpack.NormalModuleReplacementPlugin(/debug/, path.resolve(__dirname, "scripts/noop.js")),
// automatically split all vendor dependancies into a separate bundle
new webpack.optimize.CommonsChunkPlugin({
name: "js/bundle.vendor.js",
minChunks: (module) => module.context && module.context.indexOf("node_modules") !== -1
})
]
};