This repository has been archived by the owner on Apr 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.production.js
87 lines (84 loc) · 2.05 KB
/
webpack.production.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
77
78
79
80
81
82
83
84
85
86
87
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const Visualizer = require('webpack-visualizer-plugin')
const webpack = require('webpack')
const path = require('path')
process.env.NODE_ENV = 'production'
const WEBPACK_WATCH = !!process.env.WEBPACK_WATCH
module.exports = {
mode: 'production',
bail: true,
devtool: 'source-map',
entry: {
index: path.resolve('client/index.js')
},
output: {
path: path.resolve('dist'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js',
publicPath: '/assets/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
minimize: !WEBPACK_WATCH,
sourceMap: true
}
}
]
}
]
},
plugins: [
new CaseSensitivePathsPlugin(),
new webpack.optimize.MinChunkSizePlugin({
minChunkSize: 1024 * 10
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '[name].[chunkhash].css',
chunkFilename: '[name].[chunkhash].css'
}),
new ManifestPlugin({
fileName: 'manifest.json'
}),
new Visualizer({
filename: 'index.html'
})
],
optimization: {
minimizer: [
!WEBPACK_WATCH && new UglifyJsPlugin({
sourceMap: true,
parallel: true,
cache: true,
uglifyOptions: {
mangle: true,
output: {
comments: false
}
}
})
].filter(Boolean)
}
}