-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathwebpack.config.js
73 lines (63 loc) · 2.12 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
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const CleanPlugin = require('clean-webpack-plugin')
const cssnext = require('postcss-cssnext')
const production = process.env.NODE_ENV === 'production';
let plugins = [
new ExtractTextPlugin("bundle.css")
]
if (production) {
plugins = plugins.concat([
new CleanPlugin('./client/dist/assets'),
// This plugin looks for similar chunks and files
// and merges them for better caching by the user
new webpack.optimize.DedupePlugin(),
// This plugins optimizes chunks and modules by
// how much they are used in your app
new webpack.optimize.OccurenceOrderPlugin(),
// This plugin minifies all the Javascript code of the final bundle
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false, // Suppress uglification warnings
},
}),
// This plugins defines various variables that we can set to false
// in production to avoid code related to them from being compiled
// in our final bundle
new webpack.DefinePlugin({
__SERVER__: !production,
__DEVELOPMENT__: !production,
__DEVTOOLS__: !production,
'process.env': {
BABEL_ENV: JSON.stringify(process.env.NODE_ENV),
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
]);
}
module.exports = {
debug: !production,
devtool: production ? false : 'source-map',
entry: './client/src/js/main.js',
output: {
path: './client/dist/assets',
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js/,
exclude: /node_modules/,
loader: 'babel',
include: __dirname + '/client/src/js/',
},
{
test: /\.scss/,
loader: ExtractTextPlugin.extract("style", "css!postcss!sass")
}
]
},
postcss: [cssnext],
plugins: plugins
}