main
js 31 lines 675 Bytes
Raw
1 import fs from 'node:fs/promises'
2 import path from 'node:path'
3 import * as esbuild from 'esbuild'
4 import fg from 'fast-glob'
5
6 await esbuild.build({
7 entryPoints: [
8 'src/renderer/index.tsx'
9 ],
10 bundle: true,
11 sourcemap: true,
12 outfile: 'dist/renderer.js',
13 format: 'esm',
14 loader: {
15 '.png': 'file',
16 '.svg': 'dataurl'
17 }
18 })
19
20 // copy assets to the dist folder so imports from relative paths still work
21 for await (const asset of fg.stream([
22 'src/**/*.html',
23 'src/**/*.css'
24 ], {})) {
25 const dest = path.join('dist', asset)
26 const dir = path.join('dist', path.dirname(asset))
27 await fs.mkdir(dir, {
28 recursive: true
29 })
30 await fs.cp(asset, dest)
31 }