-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
44 lines (40 loc) · 1.04 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
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var BUILD_DIR = path.resolve(__dirname, 'public', 'dist');
var APP_DIR = path.resolve(__dirname, 'src');
var google_analytics = process.env.NODE_ENV === 'production' ? fs.readFileSync('src/google_analytics.html') : null;
var config = {
entry: APP_DIR + '/index.js',
module: {
loaders: [
{
test : /\.js$/,
include : APP_DIR,
loader : 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-2']
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.ejs',
google_analytics: google_analytics,
filename: path.resolve(__dirname, 'public', 'index.html')
})
],
output: {
path: BUILD_DIR,
filename: '[name].[chunkhash].js',
},
devServer: {
contentBase: path.join(__dirname, "public"),
publicPath: "/dist/",
port: 9000,
historyApiFallback: true
}
};
module.exports = config;