-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.mjs
45 lines (44 loc) · 1.18 KB
/
build.mjs
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
import useAutoprefixer from "autoprefixer";
import esbuild from "esbuild";
import postCssPlugin from "esbuild-style-plugin";
import esbuildSvelte from "esbuild-svelte";
import fs from "fs";
import sveltePreprocess from "svelte-preprocess";
import useTailwind from "tailwindcss";
console.log("Building client...");
esbuild
.build({
entryPoints: [`./src/index.ts`],
bundle: true,
outdir: `./dist`,
mainFields: ["svelte", "browser", "module", "main"],
minify: false,
sourcemap: "inline",
splitting: true,
write: true,
format: `esm`,
watch: process.argv.includes(`--watch`),
plugins: [
esbuildSvelte({
filterWarnings: (w) => !w.code.startsWith("a11y-"),
preprocess: sveltePreprocess(),
}),
postCssPlugin({
postcss: {
plugins: [useTailwind, useAutoprefixer],
},
}),
],
logLevel: "info",
target: "es6",
loader: { ".png": "file" },
})
.then(() => {
fs.copyFileSync("src/index.html", "dist/index.html");
fs.copyFileSync("logo.png", "dist/logo.png");
})
//@ts-ignore
.catch((error, location) => {
console.warn(`Errors: `, error, location);
process.exit(1);
});