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,23 +12,45 @@ module.exports = {
resolve: { resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'] extensions: ['.ts', '.tsx', '.js', '.jsx']
}, },
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: { module: {
rules: [{ rules: [{
test: /\.tsx?$/, test: /\.tsx?$/,
use: 'ts-loader', use: 'ts-loader',
exclude: '/node_modules/' exclude: '/node_modules/'
}, },
{ {
test: /\.(png|jpe?g|gif|svg)$/, test: /\.(png|jpe?g|gif|svg)$/,
use: [{ use: [{
loader: 'file-loader', loader: 'file-loader',
options: { options: {
esModule: false, 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: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new CopyWebpackPlugin({ new CopyWebpackPlugin({

View File

@ -17,10 +17,6 @@ module.exports = merge(common, {
] ]
} }
}, },
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'), template: path.join(__dirname, 'public/index.html'),

View File

@ -5,27 +5,6 @@ const path = require('path');
module.exports = merge(common, { module.exports = merge(common, {
mode: 'production', mode: 'production',
devtool: 'source-map', devtool: 'source-map',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
optimization: { optimization: {
minimize: true, 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",
},
},
}
}
}); });