mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-30 14:29:04 -05:00
added webpack build script
This commit is contained in:
parent
2ec247b7af
commit
046013ee0b
7 changed files with 126 additions and 3 deletions
|
@ -65,7 +65,8 @@
|
||||||
"Runner": false,
|
"Runner": false,
|
||||||
"Svg": false,
|
"Svg": false,
|
||||||
"Metrics": false,
|
"Metrics": false,
|
||||||
"Example": false
|
"Example": false,
|
||||||
|
"__MATTER_VERSION__": false
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended"
|
"extends": "eslint:recommended"
|
||||||
}
|
}
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ build/matter-dev.js
|
||||||
build/matter-dev.min.js
|
build/matter-dev.min.js
|
||||||
demo/js/lib/matter-dev.js
|
demo/js/lib/matter-dev.js
|
||||||
demo/js/Examples.js
|
demo/js/Examples.js
|
||||||
|
demo/js/Examples.min.js
|
||||||
examples/build
|
examples/build
|
||||||
test/browser/diffs
|
test/browser/diffs
|
||||||
test/browser/refs
|
test/browser/refs
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<script type="text/javascript" src="/demo/lib/pathseg.js"></script>
|
<script type="text/javascript" src="/demo/lib/pathseg.js"></script>
|
||||||
|
|
||||||
<!-- Matter -->
|
<!-- Matter -->
|
||||||
<script src="../build/matter-dev.js"></script>
|
<script src="../build/matter.js"></script>
|
||||||
|
|
||||||
<!-- MatterTools -->
|
<!-- MatterTools -->
|
||||||
<script src="//code.jquery.com/jquery-3.1.1.js"></script>
|
<script src="//code.jquery.com/jquery-3.1.1.js"></script>
|
||||||
|
|
|
@ -48,10 +48,17 @@
|
||||||
"through2": "^2.0.3",
|
"through2": "^2.0.3",
|
||||||
"vinyl-transform": "^1.0.0",
|
"vinyl-transform": "^1.0.0",
|
||||||
"watchify": "^3.9.0",
|
"watchify": "^3.9.0",
|
||||||
|
"webpack": "^4.39.3",
|
||||||
|
"webpack-cli": "^3.3.8",
|
||||||
|
"webpack-dev-server": "^3.8.0",
|
||||||
"yuidocjs": "^0.10.2"
|
"yuidocjs": "^0.10.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "gulp build:dev && gulp lint"
|
"test": "gulp build:dev && gulp lint"
|
||||||
|
"dev": "webpack-dev-server",
|
||||||
|
"build": "webpack --mode=production & webpack --mode=production --env.MINIMIZE",
|
||||||
|
"build-alpha": "webpack --mode=production --env.EDGE & webpack --mode=production --env.MINIMIZE --env.EDGE",
|
||||||
|
"build-examples": "webpack --config webpack.examples.config.js --mode=production --env.EDGE & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.EDGE",
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
@ -27,7 +27,7 @@ var Common = require('./Common');
|
||||||
* @readOnly
|
* @readOnly
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
Matter.version = '@@VERSION@@';
|
Matter.version = typeof __MATTER_VERSION__ !== 'undefined' ? __MATTER_VERSION__ : '*';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`.
|
* A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`.
|
||||||
|
|
65
webpack.config.js
Normal file
65
webpack.config.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
"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';
|
||||||
|
const banner = `${name} ${version} by @liabru ${date}
|
||||||
|
${pkg.homepage}
|
||||||
|
License ${pkg.license}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
entry: { [name]: './src/module/main.js' },
|
||||||
|
output: {
|
||||||
|
library: 'Matter',
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
umdNamedDefine: true,
|
||||||
|
globalObject: 'this',
|
||||||
|
path: path.resolve(__dirname, './build'),
|
||||||
|
filename: `[name]${minimize ? '.min' : ''}.js`
|
||||||
|
},
|
||||||
|
node: false,
|
||||||
|
optimization: { minimize },
|
||||||
|
performance: {
|
||||||
|
maxEntrypointSize: maxSize,
|
||||||
|
maxAssetSize: maxSize
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.BannerPlugin(banner),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
__MATTER_VERSION__: JSON.stringify(version),
|
||||||
|
})
|
||||||
|
],
|
||||||
|
externals: {
|
||||||
|
'poly-decomp': {
|
||||||
|
commonjs: 'poly-decomp',
|
||||||
|
commonjs2: 'poly-decomp',
|
||||||
|
amd: 'poly-decomp',
|
||||||
|
root: 'decomp'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
contentBase: __dirname,
|
||||||
|
open: true,
|
||||||
|
openPage: 'demo/index.html',
|
||||||
|
compress: true,
|
||||||
|
port: 8000,
|
||||||
|
proxy: {
|
||||||
|
'/build': {
|
||||||
|
target: 'http://localhost:8000/',
|
||||||
|
pathRewrite: { '^/build' : '/' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
49
webpack.examples.config.js
Normal file
49
webpack.examples.config.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
"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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in a new issue