1 Star 0 Fork 0

skyding/matter-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
liabru 提交于 2020-03-09 22:07 . changed alpha build configuration
/* 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 alpha = env.ALPHA || false;
const maxSize = minimize ? 100 * 1024 : 512 * 1024;
const isDevServer = process.env.WEBPACK_DEV_SERVER;
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
const date = new Date().toISOString().slice(0, 10);
const name = 'matter';
const alphaInfo = 'Experimental pre-release build.\n ';
const banner =
` ${pkg.name} ${version} by @liabru (c) ${date}
${alpha ? alphaInfo : ''}${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]${alpha ? '.alpha' : ''}${minimize ? '.min' : ''}.js`
},
node: false,
optimization: { minimize },
performance: {
maxEntrypointSize: maxSize,
maxAssetSize: maxSize
},
plugins: [
new webpack.BannerPlugin(banner),
new webpack.DefinePlugin({
__MATTER_VERSION__: JSON.stringify(!isDevServer ? version : '*'),
})
],
externals: {
'poly-decomp': {
commonjs: 'poly-decomp',
commonjs2: 'poly-decomp',
amd: 'poly-decomp',
root: 'decomp'
}
},
devServer: {
contentBase: [
path.resolve(__dirname, './demo'),
path.resolve(__dirname, './examples'),
path.resolve(__dirname, './build')
],
open: true,
openPage: '',
compress: true,
port: 8000,
proxy: {
'/build': {
target: 'http://localhost:8000/',
pathRewrite: { '^/build' : '/' }
},
'/examples': {
target: 'http://localhost:8000/',
pathRewrite: { '^/examples' : '/' }
}
}
}
};
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/skyding228/matter-js.git
git@gitee.com:skyding228/matter-js.git
skyding228
matter-js
matter-js
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385