Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
70 lines (64 loc) · 1.9 KB
/
Copy pathvite.config.ts
File metadata and controls
70 lines (64 loc) · 1.9 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
import fs from 'fs';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
let assetsSrcPath = 'src_assets/common/assets/web';
let assetsDstPath = 'build/assets/web';
// Allow CMake to override paths (and resolve symlinks)
if (!process.env.SUNSHINE_BUILD_HOMEBREW) {
if (process.env.SUNSHINE_SOURCE_ASSETS_DIR) {
assetsSrcPath = resolve(
fs.realpathSync(process.env.SUNSHINE_SOURCE_ASSETS_DIR),
'common/assets/web',
);
}
if (process.env.SUNSHINE_ASSETS_DIR) {
assetsDstPath = resolve(fs.realpathSync(process.env.SUNSHINE_ASSETS_DIR), 'assets/web');
}
}
const header = fs.readFileSync(resolve(assetsSrcPath, 'template_header.html'), 'utf-8');
export default defineConfig(({ mode }) => {
const isDebug = mode === 'debug';
// Dynamically include only HTML entry points that actually exist to avoid
// Rollup errors when legacy pages are removed. Primary SPA is index.html.
const candidatePages = [
'index',
'apps',
'playnite',
'clients',
'config',
'password',
'troubleshooting',
'pin',
];
const input: Record<string, string> = {};
for (const name of candidatePages) {
const p = resolve(assetsSrcPath, `${name}.html`);
if (fs.existsSync(p)) input[name] = p;
}
return {
root: resolve(assetsSrcPath),
base: './',
resolve: {
alias: { '@': resolve(assetsSrcPath) },
},
// Ensure Vue devtools can attach in Debug bundles
define: {
__VUE_PROD_DEVTOOLS__: isDebug,
},
plugins: [vue(), ViteEjsPlugin({ header })],
css: {
// Include CSS sources in sourcemaps during debug
devSourcemap: isDebug,
},
build: {
outDir: resolve(assetsDstPath),
sourcemap: isDebug ? 'inline' : false,
minify: isDebug ? false : 'esbuild',
rollupOptions: {
input,
},
},
};
});