forked from PrettyCoffee/fluidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (61 loc) · 1.81 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (61 loc) · 1.81 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
63
64
65
66
/* eslint-disable import/no-extraneous-dependencies */
import { resolve } from "path"
import { defineConfig, type PluginOption } from "vite"
export default defineConfig(async ({ command }) => {
const enableReactPlugin =
command === "serve" && process.env.VITE_DISABLE_REACT_PLUGIN !== "1"
const enableChecker =
command === "serve" &&
process.env.VITE_ENABLE_CHECKER === "1" &&
!process.env.CI &&
process.env.CODEX_CI !== "1"
const plugins: PluginOption[] = []
if (enableReactPlugin) {
const { default: react } = await import("@vitejs/plugin-react")
plugins.push(
react({
babel: {
plugins: ["@emotion/babel-plugin"],
},
}),
)
}
if (enableChecker) {
const { checker } = await import("vite-plugin-checker")
plugins.push(
checker({
typescript: true,
eslint: {
lintCommand: "eslint ./src --ext .ts,.tsx",
dev: {
logLevel: ["error"],
},
},
}),
)
}
return {
base: "./",
build: {
outDir: "build",
emptyOutDir: true,
// Chrome may warn about unused `link rel="modulepreload"` in extension pages.
// Disabling modulepreload avoids noisy Performance warnings and is fine for local extension assets.
modulePreload: false,
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
popup: resolve(__dirname, "popup.html"),
background: resolve(__dirname, "src/extension/background.ts"),
contentScript: resolve(__dirname, "src/extension/contentScript.ts"),
},
output: {
entryFileNames: "assets/[name].js",
chunkFileNames: "assets/[name]-[hash].js",
assetFileNames: "assets/[name]-[hash][extname]",
},
},
},
plugins,
}
})