mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-19 23:28:50 +08:00
26e6434b75
- hippy-vue: ElementNode add repaintWithChildren API - hippy-vue: support remove outdated style of HMR chunk - hippy-vue-loader: support style hmr - hippy-vue-css-loader: support remove outdated style of HMR chunk - debug-server, vue-demo, react-demo, hippy-react: support hmr - debug-server: add hippy-dev command
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
/* eslint-disable no-console */
|
|
|
|
const path = require('path');
|
|
const { rollup } = require('rollup');
|
|
const reactBuilds = require('./react-configs').getAllBuilds();
|
|
const vueBuilds = require('./vue-configs').getAllBuilds();
|
|
const buildDebugServer = require('./build-debug-server');
|
|
|
|
let builds = [...reactBuilds, ...vueBuilds];
|
|
|
|
// filter builds via command line arg
|
|
if (process.argv[2]) {
|
|
const filters = process.argv[2].split(',');
|
|
builds = builds.filter(b => filters.some(f => b.output.file.indexOf(f) > -1 || b.output.name.indexOf(f) > -1));
|
|
}
|
|
|
|
function blue(str) {
|
|
return `\x1b[1m\x1b[34m${str}\x1b[39m\x1b[22m`;
|
|
}
|
|
|
|
function getSize(code) {
|
|
return `${(code.length / 1024).toFixed(2)}kb`;
|
|
}
|
|
|
|
function logError(e) {
|
|
console.error(e);
|
|
}
|
|
|
|
async function buildEntry(config) {
|
|
const { output } = config;
|
|
const { file } = output;
|
|
const bundle = await rollup(config);
|
|
await bundle.generate(output);
|
|
const { output: [{ code }] } = await bundle.write(output);
|
|
console.log(`${blue(path.relative(process.cwd(), file))} ${getSize(code)}`);
|
|
}
|
|
|
|
function build(buildSets) {
|
|
let built = 0;
|
|
const total = builds.length;
|
|
const next = () => {
|
|
buildEntry(buildSets[built])
|
|
.then(() => {
|
|
built += 1;
|
|
if (built < total) {
|
|
next();
|
|
}
|
|
})
|
|
.catch(logError);
|
|
};
|
|
|
|
next();
|
|
}
|
|
|
|
build(builds);
|
|
|
|
buildDebugServer();
|