Skip to content

Commit e8e569d

Browse files
committed
Use Terser plugin to minimize and build source-map
Upgraded Webpack
1 parent eceb54e commit e8e569d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
"react-test-renderer": "^16.0.0",
7979
"sinon": "^7.1.0",
8080
"styled-components": "^4.1.3",
81-
"uglifyjs-webpack-plugin": "^0.4.6",
82-
"webpack": "^4.23.1",
81+
"webpack": "^4.29.6",
8382
"webpack-bundle-analyzer": "^2.13.1",
8483
"webpack-cli": "^3.1.2",
8584
"webpack-dev-server": "^3.1.10"

webpack.config.prod.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
const path = require('path');
22
const CleanWebpackPlugin = require('clean-webpack-plugin');
3-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
3+
const TerserPlugin = require('terser-webpack-plugin');
44
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
55

66
module.exports = {
77
mode: 'production',
8+
devtool: 'source-map',
89
entry: path.resolve(__dirname, 'lib/index'),
910
externals: {
1011
'styled-components': 'styled-components',
1112
react: 'react'
1213
},
14+
optimization: {
15+
minimizer: [
16+
new TerserPlugin({
17+
parallel: true,
18+
sourceMap: true,
19+
terserOptions: {
20+
output: {
21+
comments: false,
22+
}
23+
},
24+
}),
25+
]
26+
},
1327
output: {
1428
path: path.resolve(__dirname, 'dist'),
1529
filename: 'react-simple-chatbot.js',
@@ -23,10 +37,7 @@ module.exports = {
2337
},
2438
plugins: [
2539
new CleanWebpackPlugin(['dist']),
26-
new UglifyJsPlugin({
27-
comments: false
28-
}),
29-
process.env.BUNDLE_ANALYZE === 'true' ? new BundleAnalyzerPlugin() : () => {}
40+
process.env.BUNDLE_ANALYZE === 'true' ? new BundleAnalyzerPlugin() : () => { }
3041
],
3142
module: {
3243
rules: [

0 commit comments

Comments
 (0)