Reputation: 4454
In a minimal configuration like below, how does a webpack newbie change the default output script name?
const path = require('path');
module.exports = {
entry: "./src/myapp.js",
output: {
path: path.resolve(__dirname, 'build/js'),
filename: "[name].js"
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "lib",
chunks: "all"
}
}
}
}
}
I tried adding the 'default' cache group with customized priority and name but I always ended up having main.js in the output scripts.
My goal is to split the sources in two files with - lib.js and app.js, regardless of their size and other optimization options webpack might consider when splitting.
Upvotes: 2
Views: 2605
Reputation: 1930
You have to provide a name
for your entry file, which you havn't. Webpack defaults to main.js in this case.
module.exports = {
entry: {
"app": "./src/myapp.js"
},
... // Your other stuff
}
Upvotes: 5