2019-09-28 10:15:54 -04:00
|
|
|
/* eslint-env es6 */
|
2019-09-14 13:36:22 -04:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const path = require('path');
|
|
|
|
const pkg = require('./package.json');
|
2020-12-05 18:36:13 -05:00
|
|
|
const fs = require('fs');
|
2019-09-14 13:36:22 -04:00
|
|
|
const execSync = require('child_process').execSync;
|
|
|
|
|
|
|
|
module.exports = (env = {}) => {
|
|
|
|
const minimize = env.MINIMIZE || false;
|
2020-12-05 18:36:13 -05:00
|
|
|
const alpha = env.ALPHA || false;
|
2019-09-14 13:36:22 -04:00
|
|
|
const maxSize = minimize ? 100 * 1024 : 512 * 1024;
|
|
|
|
|
|
|
|
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
2020-12-05 18:36:13 -05:00
|
|
|
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
|
|
|
|
const license = fs.readFileSync('LICENSE', 'utf8');
|
2019-09-14 13:36:22 -04:00
|
|
|
const date = new Date().toISOString().slice(0, 10);
|
2020-12-05 18:36:13 -05:00
|
|
|
const name = 'matter-js-examples';
|
|
|
|
const alphaInfo = 'Experimental pre-release build.\n ';
|
|
|
|
const banner =
|
|
|
|
`${name} ${version} by @liabru ${date}
|
|
|
|
${alpha ? alphaInfo : ''}${pkg.homepage}
|
|
|
|
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;
|
2019-09-14 13:36:22 -04:00
|
|
|
|
|
|
|
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'
|
2021-01-28 18:27:24 -05:00
|
|
|
},
|
|
|
|
'matter-wrap': {
|
|
|
|
commonjs: 'matter-wrap',
|
|
|
|
commonjs2: 'matter-wrap',
|
|
|
|
amd: 'matter-wrap',
|
|
|
|
root: 'MatterWrap'
|
2019-09-14 13:36:22 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|