-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (51 loc) · 1.48 KB
/
Copy pathvite.config.ts
File metadata and controls
55 lines (51 loc) · 1.48 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
import { fileURLToPath, URL } from "node:url"
import { type ConfigEnv, defineConfig, loadEnv } from "vite"
import vue from "@vitejs/plugin-vue"
import vueDevTools from "vite-plugin-vue-devtools"
import { resolve } from "node:path"
import { cwd } from "node:process"
import topLevelAwait from "vite-plugin-top-level-await"
/**
* Get a path to an HTML file
* @param name The name of the file, without ".html"
* @returns The path to the file
*/
function htmlPath(name: string): string {
return resolve(__dirname, `${name}.html`)
}
/**
* Get the base URL from environment variables, or default to "/"
* @param configEnv Loaded configuration
* @returns The base URL as a string
*/
function baseURL(configEnv: ConfigEnv): string {
const env = loadEnv(configEnv.mode, cwd())
return env.VITE_BASE_URL ?? "/"
}
// https://vite.dev/config/
export default defineConfig((configEnv) => ({
base: baseURL(configEnv),
plugins: [
vue(),
vueDevTools(),
topLevelAwait(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
build: {
rollupOptions: {
input: {
main: htmlPath("index"),
horizonsdata: htmlPath("horizons-data-import"),
},
output: {
assetFileNames: "[hash:16][extname]",
chunkFileNames: "[hash:16].js",
entryFileNames: "[hash:16].js",
}
}
}
}))