forked from bornova/numara-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
55 lines (46 loc) · 1.39 KB
/
Copy pathbuild.js
File metadata and controls
55 lines (46 loc) · 1.39 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { build } from 'esbuild'
import { readFileSync, promises as fs } from 'fs'
const pkg = JSON.parse(readFileSync('./package.json'))
const buildPath = 'build'
const jsBanner = `/**
* ${pkg.description}
* Version ${pkg.version}
* Copyright ©️ ${new Date().getFullYear()} ${pkg.author.name}
*
* Licence : ${pkg.license} - ${pkg.homepage}/blob/master/LICENSE
* GitHub : ${pkg.homepage}
* Website : ${pkg.author.url}
*/`
const cssBanner = `/* ${pkg.description} ${pkg.version} */\n`
async function buildNumara() {
await fs.rm(buildPath, { recursive: true, force: true })
await fs.mkdir(buildPath, { recursive: true })
await Promise.all([
fs.cp('src/assets', `${buildPath}/assets`, { recursive: true }),
fs.cp('src/index.html', `${buildPath}/index.html`),
fs.cp('src/misc/numara.webmanifest', `${buildPath}/numara.webmanifest`)
])
await build({
banner: { css: cssBanner },
bundle: true,
minify: true,
entryPoints: ['src/css/app.css'],
outdir: `${buildPath}/css`
})
await build({
banner: { js: jsBanner },
bundle: true,
minify: true,
entryPoints: ['src/js/app.js'],
outfile: `${buildPath}/js/numara.js`,
sourcemap: !process.env.PROD
})
await build({
bundle: true,
minify: true,
entryPoints: ['src/js/calc/calc.worker.js'],
outfile: `${buildPath}/js/calc.worker.js`,
sourcemap: !process.env.PROD
})
}
buildNumara()