[wasm] build: default to release build
This commit is contained in:
parent
60d2fb4ce0
commit
b3fc9f8318
@ -56,13 +56,30 @@ async function replaceFileByRegex(filepath, ...replacementRules) {
|
||||
await writeFile(filepath, content, 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | undefined} value
|
||||
* @param [defaultValue=false]
|
||||
* @return {boolean}
|
||||
*/
|
||||
function parseBoolean(value, defaultValue = false) {
|
||||
if (value === undefined || value === null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
if (Number.isFinite(+value)) {
|
||||
return Boolean(value);
|
||||
}
|
||||
|
||||
return value.toLowerCase() === 'true';
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const wasmSourceDir = path.join(__dirname, '..', 'um_wasm');
|
||||
const wasmOutDir = path.resolve(__dirname, 'pkg');
|
||||
const wasmDistDir = path.resolve(__dirname, 'dist');
|
||||
await rm(wasmOutDir, { recursive: true, force: true });
|
||||
const wasmRelOutDir = path.relative(wasmSourceDir, wasmOutDir);
|
||||
const profileFlag = process.env.BUILD_RELEASE ? '--release' : '--dev';
|
||||
const profileFlag = parseBoolean(process.env.BUILD_RELEASE, true) ? '--release' : '--dev';
|
||||
await run(['wasm-pack', 'build', profileFlag, '--target', 'web', '--out-dir', wasmRelOutDir], {
|
||||
cwd: path.resolve(__dirname, '..', 'um_wasm'),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user