-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
121 lines (116 loc) · 3.09 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const webpack = require('webpack')
const path = require('path')
module.exports = function() {
const nodeEnv = process.env.NODE_ENV || 'development'
const isProd = nodeEnv === 'production'
const plugins = [
new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify(nodeEnv)}
})
]
if (isProd) {
plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true
},
output: {
comments: false
}
})
)
} else {
plugins.push(
new webpack.HotModuleReplacementPlugin()
)
}
const app = ['./app.js']
if (!isProd) {
app.push('webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true')
}
return {
devtool: isProd ? 'source-map' : '#cheap-module-source-map',
context: path.join(__dirname, './client'),
entry: {
app
},
output: {
path: path.join(__dirname, './public'),
filename: '[name].js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.html$/,
exclude: /node_modules/,
use: {
loader: 'file-loader',
query: {
name: '[name].[ext]'
}
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader?localIdentName=[local]__[path][name]__[hash:base64:5]&modules&importLoaders=1',
'postcss-loader'
]
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
'react-hot-loader',
'babel-loader'
]
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader'
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
},
{
test: /\.(png|jpg)$/,
loader: 'url?prefix=images/&name=[path][name].[hash:base64:5].[ext]&limit=8192'
}
]
},
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
path.join(__dirname, './client')
],
extensions: ['.js', '.jsx'],
alias: {
'containers': path.join(__dirname, 'client/containers'),
'components': path.join(__dirname, 'client/components'),
'constants': path.join(__dirname, 'client/constants'),
'common': path.join(__dirname, 'common'),
}
},
plugins
}
}