-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.babel.js
More file actions
75 lines (73 loc) · 2.13 KB
/
webpack.config.babel.js
File metadata and controls
75 lines (73 loc) · 2.13 KB
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
import AssetsPlugin from 'assets-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
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: {
preLoaders: DEBUG ? [
{
test: /\.js$/,
loader: 'eslint-loader'
}
] : [],
loaders: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', `css?modules&localIdentName=[name]${DEBUG ? '' : '-[hash:base64:4]'}`)
},
{
test: /\.scss$/,
loader: DEBUG ?
`style!css!sass?localIdentName=[name]`
: ExtractTextPlugin.extract('style', `css!sass?localIdentName=[name]-[hash:base64:4]`)
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: DEBUG ? {
plugins: [['react-transform', {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}]
}]]
} : {}
},
{
test: /\.json?$/,
loader: 'json'
},
{
test: /\.gif$|\.jpe?g$|\.woff|\.eot|\.ttf|\.png$|\.svg$/i,
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}})
]
]
}