-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.js
53 lines (43 loc) · 1.34 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { build } from 'esbuild'
import fs from 'fs-extra'
const pkg = JSON.parse(fs.readFileSync('./package.json'))
const buildPath = 'build'
fs.emptyDir(buildPath).then(() => {
const copyFiles = [
{ source: 'src/assets', target: buildPath + '/assets' },
{ source: 'src/index.html', target: buildPath + '/index.html' },
{ source: 'src/misc/numara.webmanifest', target: buildPath + '/numara.webmanifest' }
]
copyFiles.forEach(({ source, target }) => {
fs.copySync(source, target)
})
const cssBanner = `/* ${pkg.description} ${pkg.version} */\n`
const cssConfig = { banner: { css: cssBanner }, bundle: true, minify: true }
build({
...cssConfig,
entryPoints: ['src/css/app.css'],
outfile: buildPath + '/css/numara.css'
})
build({
...cssConfig,
entryPoints: ['src/css/light.css', 'src/css/dark.css'],
outdir: buildPath + '/css/'
})
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}
*/`
build({
banner: { js: jsBanner },
bundle: true,
entryPoints: ['src/js/app.js'],
minify: true,
outfile: buildPath + '/js/numara.js',
sourcemap: !process.env.PROD
})
})