-
Notifications
You must be signed in to change notification settings - Fork 0
/
esOpts.ts
54 lines (52 loc) · 1.31 KB
/
esOpts.ts
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
/** @format */
import esbuildSvelte from "esbuild-svelte"
import sveltePreprocess from "svelte-preprocess"
import htmlPlugin from "@chialab/esbuild-plugin-html"
import type {BuildOptions} from "esbuild"
export const makeBuildOptions = (dev: boolean, extra?: {define: BuildOptions["define"]}): BuildOptions & {outdir: string} => {
return {
entryPoints: ["./src/index.html"],
minify: !dev,
sourcemap: dev,
banner: {
js: `/* https://github.com/benjamingwynn/tetromino */`,
css: `/* https://github.com/benjamingwynn/tetromino */`,
},
outdir: dev ? ".esdev" : "dist",
assetNames: "assets/[name]-[hash]",
platform: "browser",
entryNames: "index",
chunkNames: "[ext]/[name]-[hash]",
bundle: true,
metafile: !dev,
loader: {
".ts": "ts",
".woff": "file",
".woff2": "file",
".ttf": "file",
".gif": "file",
".png": "file",
".svg": "dataurl",
},
plugins: [
htmlPlugin({
// styles are normally injected as javascript
// fix with: https://github.com/benjamingwynn/esbuild-plugin-html/
injectStylesAs: "link",
}),
// @ts-expect-error
esbuildSvelte({
// @ts-expect-error
preprocess: sveltePreprocess(),
compilerOptions: {
dev,
},
}),
],
define: {
DEV: String(dev),
BUILD: JSON.stringify({time: Date.now()}),
...extra?.define,
},
}
}