Unify config for webpack

This commit is contained in:
Paulo Gustavo Veiga 2021-02-16 11:11:13 -08:00
parent 493ad7fd98
commit c8a1352376
3 changed files with 36 additions and 39 deletions

View File

@ -12,6 +12,10 @@ module.exports = {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.tsx?$/,
@ -29,6 +33,24 @@ module.exports = {
},
]
},
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({

View File

@ -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'),

View File

@ -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 }
});