-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
webpack.config.js
59 lines (55 loc) · 1.85 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
// CHECK: https://tech.trivago.com/2015/12/17/export-multiple-javascript-module-formats/
// CHECK: https://github.com/vuejs/vue/blob/dev/package.json
/* Import */
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const variants = require('parallel-webpack').createVariants;
const CopyWebpackPlugin = require('copy-webpack-plugin');
/* Read license */
const license = fs.readFileSync('./LICENSE', 'utf-8');
// basically a copy of Webpack 4 production defaults, minus anything that interferes with an unminified build
function config(options) {
return {
'entry': './src/carrot.js',
'performance': {
'hints': 'warning',
},
'output': {
'pathinfo': false,
'path': path.resolve(__dirname, 'dist'),
'filename': `carrot.${options.target}${options.mode === 'development' ? '' : '.min'}.js`,
'library': 'Carrot',
'libraryTarget': options.target,
},
'plugins': [
new webpack.BannerPlugin(license),
new webpack.optimize.ModuleConcatenationPlugin(),
new CopyWebpackPlugin([{from: 'src/multithreading/workers/node/worker.js', to: '.'}]),
],
'optimization': {
'namedModules': false,
'namedChunks': false,
'flagIncludedChunks': true,
'occurrenceOrder': true,
'sideEffects': true,
'usedExports': true,
'concatenateModules': true,
'splitChunks': {
'hidePathInfo': true,
'minSize': 30000,
'maxAsyncRequests': 5,
'maxInitialRequests': 3,
},
'noEmitOnErrors': true,
'checkWasmTypes': true,
'minimize': (options.mode === 'development') ? false : true,
},
'mode': 'none', // avoid development / production defaults
};
}
/* Export config */
module.exports = variants({
target: ['window', 'commonjs2', 'amd', 'umd2'],
mode: ['development', 'production'],
}, config);