use chunks in dev

This commit is contained in:
Vitaly 2023-08-09 21:01:06 +03:00
parent a977441046
commit c6936407b2
2 changed files with 17 additions and 2 deletions

View file

@ -8,7 +8,7 @@ const config = {
entry: path.resolve(__dirname, './index.js'), entry: path.resolve(__dirname, './index.js'),
output: { output: {
path: path.resolve(__dirname, './public'), path: path.resolve(__dirname, './public'),
filename: './index.js', filename: './[name]-[chunkhash].js',
publicPath: './' publicPath: './'
}, },
resolve: { resolve: {
@ -47,7 +47,8 @@ const config = {
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: 'index.html', template: 'index.html',
hash: true, hash: true,
minify: false minify: false,
chunks: ['main', 'vendors'],
}), }),
// fix "process is not defined" error: // fix "process is not defined" error:
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({

View file

@ -19,5 +19,19 @@ module.exports = merge(common,
devMiddleware: { devMiddleware: {
writeToDisk: true, writeToDisk: true,
}, },
},
optimization: {
splitChunks: {
maxAsyncRequests: 10,
maxInitialRequests: 10,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: 10,
chunks: 'all'
}
}
}
} }
}) })