-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
65 lines (64 loc) · 1.7 KB
/
vite.config.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
55
56
57
58
59
60
61
62
63
64
65
import { defineConfig, loadEnv } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import webExtension from "@samrum/vite-plugin-web-extension";
import path from "path";
import { getManifest } from "./src/manifest";
import { windi } from "svelte-windicss-preprocess";
import sveltePreprocess from "svelte-preprocess";
import AutoImport from "unplugin-auto-import/vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [
svelte({
preprocess: [sveltePreprocess(), windi({})],
experimental: {
dynamicCompileOptions({ filename, compileOptions }) {
return {
...compileOptions,
customElement: filename.endsWith(".custom.svelte"),
};
},
},
}),
webExtension({
manifest: getManifest(),
}),
AutoImport({
imports: [
{
"webextension-polyfill": [["default", "browser"]],
},
],
}),
viteStaticCopy({
targets: [
{
src: "src/_locales",
dest: "",
},
],
}),
],
resolve: {
alias: {
"~": path.resolve(__dirname, "./src"),
},
},
build: {
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[hash].[ext]`,
},
},
sourcemap: env.WATCH === "true" ? "inline" : false,
},
optimizeDeps: {
include: ["webextension-polyfill"],
},
};
});