-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
executable file
·34 lines (30 loc) · 864 Bytes
/
build.js
File metadata and controls
executable file
·34 lines (30 loc) · 864 Bytes
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
#!/bin/env node
import * as esbuild from 'esbuild';
import * as fs from 'node:fs/promises';
await esbuild.build({
entryPoints: ['src/main.tsx'],
bundle: true,
outdir: 'build',
sourcemap: true,
minify: false,
plugins: [
{name: 'scoped-css', setup(build) {
build.onResolve({ filter: /\.css\?raw$/ }, async args => ({
path: await build.resolve(args.path.slice(0, -4), {
resolveDir: args.resolveDir,
kind: 'import-statement'
}).then(result => result.path),
namespace: 'scoped-css',
}));
build.onLoad({ filter: /.*/, namespace: 'scoped-css' }, async args => ({
contents: await fs.readFile(args.path, 'utf8'),
loader: 'text',
}))
}}
]
});
await Promise.all([
fs.copyFile('index.html', 'build/index.html'),
fs.copyFile('logo/logo.svg', 'build/logo.svg'),
fs.copyFile('manifest.json', 'build/manifest.json'),
]);