-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
36 lines (31 loc) · 1022 Bytes
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
// Run wasm-pack build --target web
exec('wasm-pack build --target web', (error, stdout, stderr) => {
if (error) {
console.error(`Error executing wasm-pack: ${error}`);
return;
}
console.log(stdout);
// Copy the .wasm file
const source = './pkg/wasm_bind_gen_block_on_bg.wasm';
const destination = './vite-project/public/wasm_bind_gen_block_on_bg.wasm';
fs.copyFile(source, destination, (err) => {
if (err) {
console.error(`Error copying file: ${err}`);
return;
}
console.log('File copied successfully.');
// Change to vite-project directory
process.chdir(path.join(__dirname, 'vite-project'));
// Run npm install
exec('npm install', (installError, installStdout, installStderr) => {
if (installError) {
console.error(`Error executing npm install: ${installError}`);
return;
}
console.log(installStdout);
});
});
});