Skip to content

Commit

Permalink
update examples build config and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Dec 5, 2020
1 parent fe80478 commit 69afb11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -35,7 +35,8 @@
"dev": "webpack-dev-server --watch-content-base",
"build": "webpack --mode=production & webpack --mode=production --env.MINIMIZE",
"build-alpha": "webpack --mode=production --env.ALPHA & webpack --mode=production --env.MINIMIZE --env.ALPHA",
"build-examples": "webpack --config webpack.examples.config.js --mode=production --env.ALPHA & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.ALPHA",
"build-examples": "webpack --config webpack.examples.config.js --mode=production & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE",
"build-examples-alpha": "webpack --config webpack.examples.config.js --mode=production --env.ALPHA & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.ALPHA",
"lint": "eslint 'src/**/*.js' 'demo/js/Demo.js' 'demo/js/Compare.js' 'examples/*.js' 'webpack.*.js'",
"doc": "yuidoc --config yuidoc.json --project-version $npm_package_version",
"test": "npm run test-node",
Expand Down
16 changes: 10 additions & 6 deletions webpack.examples.config.js
Expand Up @@ -4,20 +4,24 @@
const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const fs = require('fs');
const execSync = require('child_process').execSync;

module.exports = (env = {}) => {
const minimize = env.MINIMIZE || false;
const edge = env.EDGE || false;
const alpha = env.ALPHA || 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 version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
const license = fs.readFileSync('LICENSE', 'utf8');
const date = new Date().toISOString().slice(0, 10);
const name = 'matter-examples';
const banner = `${name} ${version} by @liabru ${date}
${pkg.homepage}
License ${pkg.license}`;
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 : ''}`;

return {
entry: './examples/index.js',
Expand Down

0 comments on commit 69afb11

Please sign in to comment.