forked from mozilla/learning.mozilla.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
67 lines (62 loc) · 1.79 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
var webpack = require('webpack');
var production = process.env.NODE_ENV === 'production';
var IMPORT_ES5_SHIM = 'imports?shim=es5-shim/es5-shim&' +
'sham=es5-shim/es5-sham';
function importEnvVars(keys) {
var result = {};
keys.forEach(function(key) {
if (typeof (process.env[key]) === 'string') {
result['process.env.' + key] = JSON.stringify(process.env[key]);
}
});
return result;
}
module.exports = {
entry: {
app: './lib/main.jsx',
manualTests: './test/browser/manual-main.jsx',
tests: './test/browser/main.js'
},
devtool: production ? process.env.WEBPACK_DEVTOOL || 'source-map'
: process.env.WEBPACK_DEVTOOL || 'eval',
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: '[name].bundle.js'
},
module: {
loaders: [
{ test: /\.jsx$/, loader: 'jsx-loader' },
// https://github.com/webpack/webpack/issues/558#issuecomment-60889168
{ test: require.resolve('react'), loader: IMPORT_ES5_SHIM },
{ test: require.resolve('react/addons'), loader: IMPORT_ES5_SHIM },
{ test: /\.json$/, loader: 'json-loader' }
]
},
plugins: [
new webpack.DefinePlugin(importEnvVars([
'LESS_AUTOPREFIXER',
'SHOW_DEV_RIBBON',
'NODE_ENV',
'TEACH_API_URL',
'GA_ACCOUNT',
'MAPBOX_ACCESS_TOKEN',
'MAPBOX_MAP_ID',
'PLEDGE_MAILINGLIST_URL',
'PLEDGE_MAILINGLIST_PRIVACY_NAME',
'OPTIMIZELY_ID',
'OPTIMIZELY_ACTIVE',
'MAKE_METADATA_URL'
])),
new webpack.optimize.CommonsChunkPlugin('commons',
'commons.bundle.js')
].concat(
production ? [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
] : []
)
};