forked from banteg/milady-shrinkifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (52 loc) · 1.39 KB
/
vite.config.ts
File metadata and controls
55 lines (52 loc) · 1.39 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
import { readFile, writeFile } from "node:fs/promises";
import { resolve } from "node:path";
import { viteStaticCopy } from "vite-plugin-static-copy";
import solid from "vite-plugin-solid";
import { defineConfig } from "vite";
import packageJson from "./package.json";
function syncManifestVersion() {
return {
name: "sync-manifest-version",
async closeBundle() {
const manifestPath = resolve(__dirname, "dist/manifest.json");
const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as { version?: string };
manifest.version = packageJson.version;
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
},
};
}
export default defineConfig({
publicDir: "public",
build: {
outDir: "dist",
emptyOutDir: true,
target: "es2022",
minify: false,
sourcemap: true,
rollupOptions: {
input: {
popup: resolve(__dirname, "popup.html"),
},
output: {
entryFileNames: "[name].js",
chunkFileNames: "chunks/[name].js",
assetFileNames: "assets/[name][extname]",
},
},
},
plugins: [
solid(),
syncManifestVersion(),
viteStaticCopy({
targets: [
{
src: [
"node_modules/onnxruntime-web/dist/*.wasm",
"node_modules/onnxruntime-web/dist/*.mjs",
],
dest: "ort",
},
],
}),
],
});