-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathwebpack.config.js
executable file
·100 lines (99 loc) · 2.5 KB
/
webpack.config.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
88
89
90
91
92
93
94
95
96
97
98
99
100
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: 'source-map',
entry: {
'js/vendors': [
'react',
'react-dom',
'prop-types',
'redux-persist/lib/persistReducer',
'redux-persist/lib/storage',
path.resolve('app/constants/actionTypes.js'),
path.resolve('app/constants/common.js'),
],
'js/bundle': path.resolve(__dirname, 'app/main.jsx'),
},
output: {
path: path.resolve(__dirname, 'public'),
filename: '[name].js',
chunkFilename: '[name].js',
},
module: {
rules: [
{
exclude: /(node_modules)/,
test: /\.(js|jsx)$/,
loader: 'babel-loader',
},
{
test: /\.(woff|woff2|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader',
},
{
test: /\.json$/,
loader: 'json-loader',
},
],
},
optimization: {
minimizer: [
new UglifyJsPlugin({
exclude: [/\.min\.js$/gi],
sourceMap: true,
uglifyOptions: {
mangle: true,
compress: {
warnings: false,
pure_getters: true,
unsafe: true,
unsafe_comps: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
},
}),
],
},
plugins: [
new CopyWebpackPlugin([{ from: 'view' }]),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
],
resolve: {
extensions: ['.js', '.jsx'],
alias: {
'@actions': path.resolve('app/actions'),
'@components': path.resolve('app/components'),
'@constants': path.resolve('app/constants'),
'@containers': path.resolve('app/containers'),
'@elements': path.resolve('app/elements'),
'@hoc': path.resolve('app/hoc'),
'@reducers': path.resolve('app/reducers'),
'@epics': path.resolve('app/epics'),
'@root': path.resolve('app'),
},
},
stats: {
colors: true,
},
};