-
Notifications
You must be signed in to change notification settings - Fork 108
/
webpack-config.js
84 lines (76 loc) · 2.65 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
74
75
76
77
78
79
80
81
82
83
84
/* ==========================================================================
Settings for webpack JavaScript bundling system.
========================================================================== */
'use strict';
var BannerFooterPlugin = require( 'banner-footer-webpack-plugin' );
var path = require( 'path' );
var paths = require( '../config/environment' ).paths;
var scriptsManifest = require( '../gulp/utils/scripts-manifest' );
var webpack = require( 'webpack' );
// Constants.
var JS_ROUTES_PATH = '/js/routes';
var COMMON_BUNDLE_NAME = 'common.js';
var modernConf = {
// jQuery is exported in the global space in the head.
externals: { jquery: 'jQuery' },
context: path.join( __dirname, '/../', paths.unprocessed, JS_ROUTES_PATH ),
entry: scriptsManifest.getDirectoryMap( paths.unprocessed +
JS_ROUTES_PATH ),
output: {
path: path.join( __dirname, 'js' ),
filename: '[name]'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME ),
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME,
[ COMMON_BUNDLE_NAME ] ),
// Change warnings flag to true to view linter-style warnings at runtime.
new webpack.optimize.UglifyJsPlugin( {
compress: { warnings: false }
} ),
// Wrap JS in raw Jinja tags so included JS won't get parsed by Jinja.
new BannerFooterPlugin( '{% raw %}', '{% endraw %}', { raw: true } )
]
};
var ieConf = {
entry: paths.unprocessed + '/js/ie/common.ie.js',
output: {
filename: 'common.ie.js'
},
plugins: [
new webpack.optimize.UglifyJsPlugin( {
compress: { warnings: false }
} )
]
};
var onDemandConf = {
context: path.join( __dirname, '/../', paths.unprocessed,
JS_ROUTES_PATH + '/on-demand' ),
entry: scriptsManifest.getDirectoryMap( paths.unprocessed +
JS_ROUTES_PATH + '/on-demand' ),
output: {
path: path.join( __dirname, 'js' ),
filename: '[name]'
},
plugins: [
// Change warnings flag to true to view linter-style warnings at runtime.
new webpack.optimize.UglifyJsPlugin( {
compress: { warnings: false }
} )
]
};
var onDemandHeaderRawConf = {
context: path.join( __dirname, '/../', paths.unprocessed,
JS_ROUTES_PATH + '/on-demand' ),
entry: './header.js',
output: {
path: path.join( __dirname, 'js' ),
filename: '[name]'
}
};
module.exports = {
onDemandHeaderRawConf: onDemandHeaderRawConf,
onDemandConf: onDemandConf,
ieConf: ieConf,
modernConf: modernConf
};