-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
52 lines (45 loc) · 1.32 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
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'client');
var APP_DIR = path.resolve(__dirname, 'client/src');
var isProduction = process.argv.indexOf('--prod') !== -1;
var plugins = [];
// At the very least, ensure we set up our Twitch client id env var
var environmentPluginConfig = {
'process.env': {
'TWITCH_CLIENT_ID': JSON.stringify(process.env.TWITCH_CLIENT_ID)
}
};
if (isProduction) {
plugins.push(new webpack.optimize.UglifyJsPlugin());
// If production we also want to also set the NODE_ENV env var so that React is
// properly minified (see https://facebook.github.io/react/docs/optimizing-performance.html#use-the-production-build)
environmentPluginConfig['process.env']['NODE_ENV'] = JSON.stringify('production');
}
plugins.push(new webpack.DefinePlugin(environmentPluginConfig));
var config = {
entry: APP_DIR + '/index.js',
output: {
path: BUILD_DIR,
filename: 'bundle.js'
},
plugins: plugins,
module: {
loaders: [
{
test: /\.jsx?/,
include: APP_DIR,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
},
{
test: /\.svg$/,
loader: 'svg-inline',
include: path.join(__dirname, 'client/src')
}
]
}
};
module.exports = config;