-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
49 lines (45 loc) · 1.53 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
import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import loadVersion from "vite-plugin-package-version";
import graphql from "@rollup/plugin-graphql";
// import monacoEditorPlugin from "vite-plugin-monaco-editor";
import monacoEditorPluginModule from "vite-plugin-monaco-editor";
// A temporary fix for the issue on vite-plugin-monaco-editor:
// https://github.com/vdesjs/vite-plugin-monaco-editor/issues/21#issuecomment-1827562674
const isObjectWithDefaultFunction = (
module: unknown
): module is { default: typeof monacoEditorPluginModule } =>
module != null &&
typeof module === "object" &&
"default" in module &&
typeof module.default === "function";
const monacoEditorPlugin = isObjectWithDefaultFunction(monacoEditorPluginModule)
? monacoEditorPluginModule.default
: monacoEditorPluginModule;
//
export default ({ mode }) => {
// loadEnv: https://stackoverflow.com/a/66389044/7309855
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
server: { port: 8081 },
esbuild: { target: "es2022" },
plugins: [
vue(),
loadVersion(),
// @ts-ignore
graphql(),
monacoEditorPlugin({
languageWorkers: ["editorWorkerService"],
publicPath: "monacoeditorwork", // default
}),
],
base: process.env.VITE_PUBLIC_PATH,
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
path: "path-browserify",
},
},
});
};