forked from salgum1114/react-design-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
73 lines (71 loc) · 2.21 KB
/
webpack.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
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const WorkboxPlugin = require('workbox-webpack-plugin');
const baseConfig = require('./webpack.common.js');
const pathsToClean = [
'js',
];
const cleanOptions = {
root: path.resolve(__dirname, 'public'),
verbose: true,
};
const plugins = [
// 로더들에게 옵션을 넣어주는 플러그인
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
// index.html 로 의존성 파일들 inject해주는 플러그인
new HtmlWebpackPlugin({
filename: 'index.html',
title: 'React Design Editor',
}),
new WorkboxPlugin.InjectManifest({
swSrc: './src/sw.js',
swDest: 'sw.js',
}),
new CleanWebpackPlugin(pathsToClean, cleanOptions),
];
module.exports = merge(baseConfig, {
mode: 'production',
entry: {
vendor: [
'react',
'react-dom',
'lodash',
'fabric',
],
app: ['@babel/polyfill', path.resolve(__dirname, 'src/index.js')],
},
output: {
// entry에 존재하는 app.js, vendor.js로 뽑혀 나온다.
path: path.resolve(__dirname, 'public'),
filename: 'js/[name].[chunkhash:16].js',
chunkFilename: 'js/[id].[chunkhash:16].js',
publicPath: './',
},
optimization: {
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
warnings: false,
compress: {
warnings: false,
unused: true, // tree shaking(export된 모듈 중 사용하지 않는 모듈은 포함하지않음)
},
ecma: 6,
mangle: true,
unused: true,
},
sourceMap: true,
}),
],
},
plugins,
});