-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathvite.config.ts
More file actions
90 lines (84 loc) · 2.56 KB
/
Copy pathvite.config.ts
File metadata and controls
90 lines (84 loc) · 2.56 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
80
81
82
83
84
85
86
87
88
89
90
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { fileURLToPath, URL } from "url";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
// https://github.com/vuetifyjs/vuetify-loader/tree/next/packages/vite-plugin
import vuetify from "vite-plugin-vuetify";
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
function stripShebangPlugin() {
return {
name: "strip-shebang",
transform(code: string, id: string) {
if (id.includes("yosys2digitaljs") && code.startsWith("#!")) {
return { code: code.replace(/^#!.*/, ""), map: null };
}
return null;
},
};
}
function wasmMimePlugin() {
return {
name: "wasm-mime-type",
configureServer(server: any) {
server.middlewares.use((req: any, res: any, next: any) => {
const pathname = (req.url || "").split("?")[0];
if (pathname.endsWith(".wasm")) {
res.setHeader("Content-Type", "application/wasm");
}
next();
});
},
};
}
// https://vitejs.dev/config/
export default defineConfig(() => {
const version = process.env.VITE_SIM_VERSION || "v0";
const isDesktop = !!process.env.DESKTOP_MODE;
return {
plugins: [
stripShebangPlugin(),
wasmMimePlugin(),
vue(),
vuetify({ autoImport: true }),
cssInjectedByJsPlugin(),
VueI18nPlugin({
strictMessage: false,
}),
],
optimizeDeps: {
// Vue is excluded from pre-bundling: bundling its esm-bundler runtime
// alongside vuetify + vue-i18n triggers a runtime
// "init_runtime_dom_esm_bundler is not defined" ReferenceError in dev.
exclude: ["@yowasp/yosys", "vue"],
},
resolve: {
alias: {
"#": fileURLToPath(new URL(`./${version}/src`, import.meta.url)),
"@": fileURLToPath(new URL(`./${version}/src/components`, import.meta.url)),
},
},
root: fileURLToPath(new URL(`./${version}`, import.meta.url)),
base: process.env.VITE_BASE || (isDesktop ? "/" : `/simulatorvue/${version}/`),
build: {
outDir: fileURLToPath(new URL(`./dist/simulatorvue/${version}/`, import.meta.url)),
assetsDir: "assets",
chunkSizeWarningLimit: 1600,
rollupOptions: {
output: {
entryFileNames: `simulator-${version}.js`,
chunkFileNames: `assets/[name]-[hash].js`,
assetFileNames: `assets/[name]-[hash].[ext]`,
},
},
},
server: {
port: 4000,
watch: {
ignored: ["**/src-tauri/target/**"],
},
},
preview: {
port: 4173,
},
};
});