From c6936407b2a889682a97f708e19f4b47471efc46 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Wed, 9 Aug 2023 21:01:06 +0300 Subject: [PATCH] use chunks in dev --- webpack.common.js | 5 +++-- webpack.dev.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/webpack.common.js b/webpack.common.js index 5494e79..7c0392c 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -8,7 +8,7 @@ const config = { entry: path.resolve(__dirname, './index.js'), output: { path: path.resolve(__dirname, './public'), - filename: './index.js', + filename: './[name]-[chunkhash].js', publicPath: './' }, resolve: { @@ -47,7 +47,8 @@ const config = { new HtmlWebpackPlugin({ template: 'index.html', hash: true, - minify: false + minify: false, + chunks: ['main', 'vendors'], }), // fix "process is not defined" error: new webpack.ProvidePlugin({ diff --git a/webpack.dev.js b/webpack.dev.js index dbfbae6..c559397 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -19,5 +19,19 @@ module.exports = merge(common, devMiddleware: { writeToDisk: true, }, + }, + optimization: { + splitChunks: { + maxAsyncRequests: 10, + maxInitialRequests: 10, + cacheGroups: { + vendors: { + test: /[\\/]node_modules[\\/]/, + name: "vendors", + priority: 10, + chunks: 'all' + } + } + } } })