checkpoint kiri module migration work
This commit is contained in:
parent
e341b98849
commit
7d22cc1029
201 changed files with 41262 additions and 85 deletions
|
|
@ -8,13 +8,19 @@ const isProd = mode === 'prod';
|
|||
|
||||
console.log(`Building in ${mode} mode...`);
|
||||
|
||||
const MESH_OUTFILE = 'src2/pack/mesh.js';
|
||||
const MESH_OUTFILE = 'src2/pack/mesh-main.js';
|
||||
const MESH_EXTRAS = [
|
||||
'mod/*/mesh.js',
|
||||
'mod/*/tra1.js'
|
||||
];
|
||||
|
||||
async function appendExtraModules(extras, minify = false) {
|
||||
const KIRI_OUTFILE = 'src2/pack/kiri-main.js';
|
||||
const KIRI_EXTRAS = [
|
||||
'mod/*/kiri.js',
|
||||
'mod/*/tra1.js'
|
||||
];
|
||||
|
||||
async function appendExtraModules(extras, outfile, minify = false) {
|
||||
const files = await glob(extras);
|
||||
if (files.length === 0) return;
|
||||
|
||||
|
|
@ -32,13 +38,13 @@ async function appendExtraModules(extras, minify = false) {
|
|||
})
|
||||
);
|
||||
|
||||
await fs.appendFile(MESH_OUTFILE, transformed.join(''));
|
||||
console.log(`Appended ${files.length} module(s) to ${MESH_OUTFILE}`);
|
||||
await fs.appendFile(outfile, transformed.join(''));
|
||||
console.log(`Appended ${files.length} module(s) to ${outfile}`);
|
||||
}
|
||||
|
||||
async function buildApp() {
|
||||
try {
|
||||
// Bundle main app
|
||||
// Bundle mesh main app
|
||||
await build({
|
||||
entryPoints: [ 'src2/main/mesh.js' ],
|
||||
bundle: true,
|
||||
|
|
@ -54,13 +60,47 @@ async function buildApp() {
|
|||
}
|
||||
});
|
||||
|
||||
appendExtraModules(MESH_EXTRAS, isProd);
|
||||
appendExtraModules(MESH_EXTRAS, MESH_OUTFILE, isProd);
|
||||
|
||||
// Bundle worker
|
||||
// Bundle mesh worker
|
||||
await build({
|
||||
entryPoints: [ 'src2/mesh/work.js' ],
|
||||
bundle: true,
|
||||
outfile: 'src2/pack/work.js',
|
||||
outfile: 'src2/pack/mesh-work.js',
|
||||
format: 'esm',
|
||||
external: ['module'],
|
||||
sourcemap: !isProd, // true for dev, false for prod
|
||||
minify: isProd, // false for dev, true for prod
|
||||
target: 'es2020',
|
||||
platform: 'browser',
|
||||
define: {
|
||||
'process.env.NODE_ENV': `"${mode}"`
|
||||
}
|
||||
});
|
||||
|
||||
// Bundle mesh main app
|
||||
await build({
|
||||
entryPoints: [ 'src2/main/kiri.js' ],
|
||||
bundle: true,
|
||||
outfile: KIRI_OUTFILE,
|
||||
format: 'esm',
|
||||
external: ['module'],
|
||||
sourcemap: !isProd, // true for dev, false for prod
|
||||
minify: isProd, // false for dev, true for prod
|
||||
target: 'es2020',
|
||||
platform: 'browser',
|
||||
define: {
|
||||
'process.env.NODE_ENV': `"${mode}"`
|
||||
}
|
||||
});
|
||||
|
||||
appendExtraModules(KIRI_EXTRAS, KIRI_OUTFILE, isProd);
|
||||
|
||||
// Bundle mesh worker
|
||||
await build({
|
||||
entryPoints: [ 'src2/kiri-run/worker.js' ],
|
||||
bundle: true,
|
||||
outfile: 'src2/pack/kiri-work.js',
|
||||
format: 'esm',
|
||||
external: ['module'],
|
||||
sourcemap: !isProd, // true for dev, false for prod
|
||||
|
|
|
|||
Loading…
Reference in a new issue