-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
62 lines (61 loc) · 1.52 KB
/
build.js
File metadata and controls
62 lines (61 loc) · 1.52 KB
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
55
56
57
58
59
60
61
62
import esbuild from "esbuild";
import { readFile } from "fs/promises";
await Promise.all([
/**
* Builds the main lib index.js
* Can be used in either node or browser contexts
*/
esbuild.build({
entryPoints: ["./src/index.ts"],
platform: "neutral",
outfile: "./dist/index.js",
bundle: true,
}),
/**
* Builds the minified code required at the document head
* to support the `css` attribute for server side rendering
*/
esbuild.build({
entryPoints: ["./src/client.ts"],
platform: "browser",
outfile: "./dist/client.js",
minify: true,
bundle: true,
}),
/**
* Builds styles.css file
*/
esbuild.build({
entryPoints: ["./src/styles.css"],
platform: "browser",
outfile: "./dist/styles.css",
minify: true,
bundle: true,
plugins: [
// Leaving this here in case we want something in future
// {
// name: "ninjass-css-helpers",
// setup(build) {
// build.onLoad({ filter: /.css$/ }, async (args) => {
// let text = await readFile(args.path, "utf8");
// return {
// contents: text.replaceAll(
// / lightDark\((.+)\)/g,
// " light-dark(var(--p-l-$1), var(--p-d-$1))"
// ),
// loader: "css",
// };
// });
// },
// },
],
}),
/**
* Builds the vite plugin
*/
esbuild.build({
entryPoints: ["./src/vitePlugin.ts"],
platform: "node",
outfile: "./dist/vitePlugin.js",
}),
]);