-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildModule.js
28 lines (26 loc) · 1.11 KB
/
buildModule.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
const fs = require('fs/promises');
const {exec} = require('child_process');
function cmd(command) {
return new Promise((resolve, reject) => {
console.log(command);
const proc = exec(command);
proc.stdout.on('data', function (data) {process.stdout.write(data)});
proc.stderr.on('data', function (data) {process.stderr.write(data)});
proc.on('exit', function (code) {code === 0 ? resolve(0) : reject(code)});
});
}
(async () => {
// if exists, remove './lib/dist' folder
await fs.rm('./lib/dist', {
force: true,
recursive: true,
});
// compile elm app
await cmd(`npx elm make src/MainEmbeddable.elm ${process.argv[2] === 'dev' ? '' : '--optimize '}--output lib/dist/elm-editor.js`);
// compile react component
await cmd("npx babel --extensions '.jsx' src --out-dir lib/dist");
// isolate css files
await cmd("npx isolate-css-cli -r -p tableaueditor-Obry4K9MqH -c -o lib/dist/static/css -u 2 src/static");
// copy font files used by isolated css
await cmd("npx copyfiles -u 3 src/static/webfonts/* lib/dist/static/webfonts");
})()