-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
76 lines (74 loc) · 2.4 KB
/
webpack.config.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.config.common.js');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
module.exports = merge(common, {
mode: 'production',
cache: false,
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
uglifyOptions: {
compress: {
warnings: true
},
output: {
comments: false
}
}
}),
new OptimizeCssAssetsPlugin({})
]
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|src\/plugins)/,
use: [
'babel-loader',
'eslint-loader'
]
},
{
test: /\.(sass|scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { minimize: true } },
{
loader: 'postcss-loader',
options: {
plugins: () => [require('autoprefixer')({
'browsers': ['> 1%', 'last 2 versions']
})],
}
},
'sass-loader'
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new CleanWebpackPlugin(['public/assets'], {
root: __dirname,
verbose: true,
dry: false
}),
new OptimizeCssAssetsPlugin({
cssProcessorOptions: { discardComments: { removeAll: true } },
canPrint: true
}),
new webpack.ContextReplacementPlugin(
/moment[\/\\]locale$/,
/en-gb|ru/
),
]
});