From e698d84f9cf4c3d05920b626d61071ce67a4e49a Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 16 Feb 2021 11:11:13 -0800 Subject: [PATCH] Unify config for webpack --- packages/webapp/webpack.common.js | 48 ++++++++++++++++++++++--------- packages/webapp/webpack.dev.js | 4 --- packages/webapp/webpack.prod.js | 23 +-------------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/packages/webapp/webpack.common.js b/packages/webapp/webpack.common.js index 693cdd92..372202eb 100644 --- a/packages/webapp/webpack.common.js +++ b/packages/webapp/webpack.common.js @@ -12,23 +12,45 @@ module.exports = { resolve: { extensions: ['.ts', '.tsx', '.js', '.jsx'] }, + output: { + filename: '[name].bundle.js', + path: path.resolve(__dirname, 'dist') + }, module: { rules: [{ - test: /\.tsx?$/, - use: 'ts-loader', - exclude: '/node_modules/' - }, - { - test: /\.(png|jpe?g|gif|svg)$/, - use: [{ - loader: 'file-loader', - options: { - esModule: false, - } - }] - }, + test: /\.tsx?$/, + use: 'ts-loader', + exclude: '/node_modules/' + }, + { + test: /\.(png|jpe?g|gif|svg)$/, + use: [{ + loader: 'file-loader', + options: { + esModule: false, + } + }] + }, ] }, + optimization: { + usedExports: true, + splitChunks: { + cacheGroups: { + vendors: { + test: /node_modules\/(?!antd\/).*/, + name: "vendors", + chunks: "all", + }, + // This can be your own design library. + antd: { + test: /node_modules\/(antd\/).*/, + name: "antd", + chunks: "all", + }, + }, + } + }, plugins: [ new CleanWebpackPlugin(), new CopyWebpackPlugin({ diff --git a/packages/webapp/webpack.dev.js b/packages/webapp/webpack.dev.js index 0ee1a214..298d9e6c 100644 --- a/packages/webapp/webpack.dev.js +++ b/packages/webapp/webpack.dev.js @@ -17,10 +17,6 @@ module.exports = merge(common, { ] } }, - output: { - filename: 'bundle.js', - path: path.resolve(__dirname, 'dist') - }, plugins: [ new HtmlWebpackPlugin({ template: path.join(__dirname, 'public/index.html'), diff --git a/packages/webapp/webpack.prod.js b/packages/webapp/webpack.prod.js index af964d8e..1a8605cc 100644 --- a/packages/webapp/webpack.prod.js +++ b/packages/webapp/webpack.prod.js @@ -5,27 +5,6 @@ const path = require('path'); module.exports = merge(common, { mode: 'production', devtool: 'source-map', - output: { - filename: '[name].bundle.js', - path: path.resolve(__dirname, 'dist') - }, optimization: { - minimize: true, - usedExports: true, - splitChunks: { - cacheGroups: { - vendors: { - test: /node_modules\/(?!antd\/).*/, - name: "vendors", - chunks: "all", - }, - // This can be your own design library. - antd: { - test: /node_modules\/(antd\/).*/, - name: "antd", - chunks: "all", - }, - }, - } - } + minimize: true } });