forked from concord-consortium/codap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
59 lines (54 loc) · 1.77 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
/* global process */
var webpack = require('webpack'),
WebpackShellPlugin = require('webpack-shell-plugin');
var production = (process.env.NODE_ENV === 'production'),
plugins = [];
/*
* Configure production-only plugins
*/
if (production) {
plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}));
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
// ignore warnings from uglify
warnings: false
}
}));
}
/*
* Uglify plugin requires that bundle have .js extension for minimization to occur.
* But the SproutCore build system fails if the bundle is in the application folder
* and has a .js extension because the YUI compressor chokes on the minimized bundle.
* Therefore, we build the bundle with a .js extension initially and then rename it
* with the .js.ignore extension after all plugins have run.
*/
var bundlePath = 'apps/dg/resources/build',
srcBundleName = 'codap-lib-bundle.js',
dstBundleName = 'codap-lib-bundle.js.ignore',
srcBundle = bundlePath + '/' + srcBundleName,
dstBundle = bundlePath + '/' + dstBundleName,
echoCmd = "echo Renaming '" + srcBundleName + "' to '" + dstBundleName + "'...\n",
renameBundleCmd = ['mv', srcBundle, dstBundle].join(' ');
plugins.push(new WebpackShellPlugin({
onBuildEnd: [echoCmd, renameBundleCmd]
}));
/*
* Configuration
*/
var config = {
entry: './webpack-entry.js',
output: {
path: bundlePath,
filename: srcBundleName
},
plugins: plugins,
performance: {
// turn off bundle size warnings
hints: false
}
};
module.exports = config;