-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
73 lines (69 loc) · 2.23 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
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var BUILD_DIR = path.resolve(__dirname, 'build');
var APP_DIR = path.resolve(__dirname, 'src');
var APP_ENTRY = process.env.APP_ENTRY || "main";
var config = {
entry: {
javascript: APP_DIR + '/apps/' + APP_ENTRY + '.js'
},
devServer: {
host: "0.0.0.0",
},
devtool: 'sourcemap',
output: {
path: BUILD_DIR,
publicPath: process.env.PUBLIC_ROOT || "/",
//NOTE: when process.env.PROD is true this will be the minified file
//TODO: maybe we should hash this and figure out a way to pass the hashed version to it
filename: APP_ENTRY + '.js'
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
},
module : {
loaders : [
{
test : /\.jsx?$/,
include : APP_DIR,
loader : 'babel-loader'
},
{
test: /\.json$/,
loader: "file-loader?name=[name].[ext]",
}
]
},
plugins : [
new HtmlWebpackPlugin({
template: 'local/index.html',
inject: 'body',
//hash: true,
filename: 'index.html',
staticPath: (process.env.STATIC_ROOT || ''),
cssPath: (process.env.NODE_ENV == 'production'
? 'https://s3.amazonaws.com/mop-static/css/moui.css'
: '/css/moui.css')
}),
((process.env.PROD)
? new webpack.optimize.UglifyJsPlugin({sourceMap: true})
: new webpack.HotModuleReplacementPlugin()),
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify(((process.env.PROD) ? 'production' : 'development')),
'API_URI': JSON.stringify(process.env.API_URI ||
(process.env.PROD ? '' : '/local')
),
'API_WRITABLE': process.env.API_WRITABLE || process.env.PROD,
'BASE_APP_PATH': JSON.stringify(process.env.BASE_APP_PATH || '/'),
'SESSION_COOKIE_NAME': JSON.stringify(process.env.SESSION_COOKIE_NAME || 'SO_SESSION'),
'STATIC_ROOT': JSON.stringify(process.env.STATIC_ROOT || ''),
'TRACK_SHARE_URL': JSON.stringify(process.env.TRACK_SHARE_URL || ''),
'PROD': process.env.PROD
}
})
]
};
module.exports = config;