Answer the question
In order to leave comments, you need to log in
How to include different vendor scripts for different pages in Webpack?
I have a multi-page project that is built by Webpack.
I specified several entry points in the config:
entry: {
'main': './src/main.js',
'page.a': './src/page.a.js',
'page.b': './src/page.b.js'
}
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/].*\.js$/,
chunks: 'all'
}
}
}
new HtmlWebpackPlugin({
template: `${paths.src}/template/pages/main.pug`,
filename: 'main.html'
}),
new HtmlWebpackPlugin({
template: `${paths.src}/template/pages/page.a.pug`,
filename: 'page.a.html'
}),
new HtmlWebpackPlugin({
template: `${paths.src}/template/pages/page.b.pug`,
filename: 'page.b.html'
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question