-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
80 lines (78 loc) · 2.07 KB
/
webpack.config.babel.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
import AssetsPlugin from 'assets-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import autoprefixer from 'autoprefixer';
import nested from 'postcss-nested';
import path from 'path';
import webpack from 'webpack';
const DEBUG = process.env.NODE_ENV !== 'production';
export default {
entry: DEBUG ? [
'webpack-hot-middleware/client',
'./index.js'
] : './index.js',
context: path.resolve(__dirname, './client'),
output: {
filename: `[name]${DEBUG ? '' : '.[hash]'}.js`,
hashDigestLength: 7,
path: path.resolve(__dirname, './build'),
publicPath: '/'
},
module: {
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', `css?modules&importLoaders=1&localIdentName=[name]__[local]${DEBUG ? '' : '-[hash:base64:4]'}!postcss`),
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: DEBUG ? {
plugins: [['react-transform', {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}]
}]]
} : {}
},
{
test: /\.(eot|gif|jpe?g|png|svg|woff2?|ttf)$/,
loader: `url?limit=10000&name=[name]${DEBUG ? '' : '.[hash:7]'}.[ext]`,
exclude: /node_modules/
}
]
},
plugins: [
new AssetsPlugin({
filename: 'assets.json',
path: 'build'
}),
new ExtractTextPlugin(`[name]${DEBUG ? '' : '.[hash]'}.css`),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(DEBUG ? 'development' : 'production')
}),
...DEBUG ? [
new webpack.HotModuleReplacementPlugin()
] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
],
postcss: [
nested(),
autoprefixer({
browsers: [
'> 1%',
'last 2 versions'
]
})
]
};