-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
68 lines (66 loc) · 1.62 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
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: './src/app.js',
output: {
filename: '[name].js',
path: './dist'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]'
},
{
test: /\.css$/,
loader: NODE_ENV === 'production' ? ExtractTextPlugin.extract('style-loader', 'css-loader?{"minimize":true}!postcss-loader')
: 'style-loader!css-loader?{"minimize":true}!postcss-loader'
},
{
test: /\.ico$/,
loader: 'file?name=[name].[ext]'
},
{
test: /\.png$/,
loader: 'file?name=img/[name].[ext]'
},
{
test: /\.woff2?$/,
loader: 'file?name=fonts/[name].[ext]'
}
]
},
postcss: function(webpack) {
return [
require('postcss-import')({
addDependencyTo: webpack
}),
require('precss'),
require('autoprefixer')
];
},
plugins: NODE_ENV === 'production' ? [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(NODE_ENV)
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/en$/),
new ExtractTextPlugin('[name].css')
] : []
};