-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
79 lines (74 loc) · 2.31 KB
/
vite.config.ts
File metadata and controls
79 lines (74 loc) · 2.31 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
67
68
69
70
71
72
73
74
75
76
77
78
79
import { fileURLToPath, URL } from "node:url";
import graphql from "@rollup/plugin-graphql";
import vue from "@vitejs/plugin-vue";
import { visualizer } from "rollup-plugin-visualizer";
import { defineConfig, loadEnv } from "vite";
import monacoEditorPluginModule from "vite-plugin-monaco-editor";
// import monacoEditorPlugin from "vite-plugin-monaco-editor";
import loadVersion from "vite-plugin-package-version";
import vuetify from "vite-plugin-vuetify";
// 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 }: { mode: string }) => {
// 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(),
vuetify({
autoImport: { labs: true },
styles: { configFile: "src/styles/vuetify.scss" },
}),
loadVersion(),
// @ts-ignore
graphql(),
monacoEditorPlugin({
languageWorkers: ["editorWorkerService"],
publicPath: "monacoeditorwork", // default
}),
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
filename: "dist/stats.html", // will be saved in project's root
}),
],
build: {
rollupOptions: {
output: {
manualChunks: {
"monaco-editor-import": ["@/utils/monaco-editor"],
"monaco-editor": ["monaco-editor"],
},
},
},
},
optimizeDeps: {
include: ["monaco-editor"],
},
base: process.env.VITE_PUBLIC_PATH,
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
path: "path-browserify",
},
},
define: {
// for vitest in-source tests
"import.meta.vitest": "undefined",
},
});
};