forked from liabru/matter-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.examples.config.js
50 lines (46 loc) · 1.49 KB
/
webpack.examples.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
/* eslint-env es6 */
"use strict";
const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const execSync = require('child_process').execSync;
module.exports = (env = {}) => {
const minimize = env.MINIMIZE || false;
const edge = env.EDGE || false;
const maxSize = minimize ? 100 * 1024 : 512 * 1024;
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
const version = !edge ? pkg.version : `${pkg.version}-alpha-${commitHash}`;
const date = new Date().toISOString().slice(0, 10);
const name = 'matter-examples';
const banner = `${name} ${version} by @liabru ${date}
${pkg.homepage}
License ${pkg.license}`;
return {
entry: './examples/index.js',
output: {
library: 'Example',
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: 'this',
path: path.resolve(__dirname, './demo/js'),
filename: `Examples${minimize ? '.min' : ''}.js`
},
node: false,
optimization: { minimize },
performance: {
maxEntrypointSize: maxSize,
maxAssetSize: maxSize
},
plugins: [
new webpack.BannerPlugin(banner)
],
externals: {
'matter-js': {
commonjs: 'matter-js',
commonjs2: 'matter-js',
amd: 'matter-js',
root: 'Matter'
}
}
};
};