-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
92 lines (79 loc) · 1.89 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
85
86
87
88
89
90
91
92
/**
* This is the configuration file for webpack. It is designed to work side-by-side with gulp. We do
* not use webpack as a task runner, instead us gulp.
*/
const webpack = require('webpack');
module.exports = {
/**
* This is the entry point
*/
entry: './src/js/main.js',
/**
* We enable source maps, but do not reference it in the bundle to save space
*
* Prod: none
* Dev: source-map
*/
devtool: 'none',
/**
* The name of the bundle
*/
output: {
filename: 'main.bundle.js'
},
module: {
rules: [{
/**
* We look for all JS files, and optionally JSX files
*/
test: /\.jsx?$/,
/**
* Ignore all the npm files otherwise it'd be super big
*/
exclude: /(node_modules|bower_components)/,
/**
* When the test is matched, use babel-loader to transplile to ES5
*/
use: {
loader: 'babel-loader',
options: {
/**
* Enable Caching can speed up transpiling by 2x
*/
cacheDirectory: true,
/**
* This preset replaces the old ES2015 prest
*/
presets: ['babel-preset-env'],
/**
* This will make your code smaller by adding all the polyfills at once at
* the top of the JS File. If you don't use much JS, then comment this out
* as you probably don't want all the polyfills
*/
plugins: ['transform-runtime'],
}
}
}],
},
/**
* Enable parallel processing of JS
*/
parallelism: 4,
plugins: [
/**
* Uglify the output, but still generate a sitemap
*/
new webpack.optimize.UglifyJsPlugin({
parallel: true,
sourceMap: true
}),
],
/**
* Set the target environment to 'web'
*/
target: 'web',
/**
* Do not watch by default, we do it via gulp
*/
watch: false,
};