Skip to content

Commit 7ef0a94

Browse files
committed
[core] Add autoprefixer and css minification
1 parent 8d8e5e0 commit 7ef0a94

File tree

4 files changed

+1028
-23
lines changed

4 files changed

+1028
-23
lines changed

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"start": "webpack-dev-server",
1111
"build": "NODE_ENV=production webpack"
1212
},
13+
"browserslist": [
14+
"> 1%",
15+
"last 2 versions"
16+
],
1317
"devDependencies": {
1418
"@babel/core": "^7.11.1",
1519
"@babel/plugin-proposal-class-properties": "^7.10.4",
@@ -32,12 +36,16 @@
3236
"less-loader": "^6.2.0",
3337
"mini-css-extract-plugin": "^0.9.0",
3438
"open-browser-webpack-plugin": "^0.0.5",
39+
"optimize-css-assets-webpack-plugin": "^5.0.3",
40+
"postcss-loader": "^3.0.0",
3541
"style-loader": "^1.2.1",
42+
"terser-webpack-plugin": "^4.0.0",
3643
"webpack": "^4.44.1",
3744
"webpack-cli": "^3.3.12",
3845
"webpack-dev-server": "^3.11.0"
3946
},
4047
"dependencies": {
48+
"autoprefixer": "^9.8.6",
4149
"classnames": "^2.2.6",
4250
"normalize.css": "^8.0.1",
4351
"prop-types": "^15.7.2",

postcss.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const autoprefixer = require('autoprefixer');
2+
3+
module.exports = {
4+
plugins: [autoprefixer],
5+
};

webpack.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const webpack = require('webpack');
33
const HtmlWebpackPlugin = require('html-webpack-plugin');
44
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
55
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6+
const TerserJSPlugin = require('terser-webpack-plugin');
7+
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
68
const babelrc = require('./.babelrc');
79

810
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development';
@@ -13,6 +15,10 @@ const output = path.join(__dirname, './dist');
1315
module.exports = {
1416
mode,
1517

18+
optimization: {
19+
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
20+
},
21+
1622
devServer: {
1723
port,
1824
compress: true,
@@ -86,6 +92,7 @@ module.exports = {
8692
},
8793
},
8894
'less-loader',
95+
...(mode === 'production' ? ['postcss-loader'] : []),
8996
],
9097
},
9198

0 commit comments

Comments
 (0)