-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathwebpack.config.js
58 lines (50 loc) · 1.52 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
const path = require('path');
// A few constants we'll make use of
const MODE = process.env.npm_lifecyle_event;
const PATHS = {
src: path.join(__dirname + '/src'),
public: path.join(__dirname + '/public'),
};
// The "default" configuration, options that work for both
// the default build process as well as the development server
const config = {
entry: ['babel-polyfill', path.join(PATHS.src, '/app.js')],
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: PATHS.public,
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
include: PATHS.src,
query: {
cacheDirectory: true,
presets: ['es2015', 'react']
}
}]
}
};
// "start" is just the name of the script in our package.json for the
// development server. If it's anything except "start", we just return the
// common configuration.
if(MODE === 'start') {
// We don't need or want to run hot-module-replacement code in
// ordinary build processes, so we'll push it into the presets stack here.
config.module.loaders[0].query.presets.push('react-hmre');
// Configure our development server
config.devServer = {
contentBase: __dirname,
hot: true,
progress: true,
stats: 'errors-only',
host: process.env.HOST,
port: process.env.PORT
};
}
// Good to go!
module.exports = config;