-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvite.config.js
More file actions
66 lines (59 loc) · 1.89 KB
/
vite.config.js
File metadata and controls
66 lines (59 loc) · 1.89 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
// vite.config.js (ESM)
import { defineConfig } from 'vite';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import fs from 'fs';
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = __dirname; // adjust if your html files live elsewhere
function collectHtmlEntriesFromDir(dirPath, keyPrefix) {
if (!fs.existsSync(dirPath)) return {};
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
const out = {};
for (const entry of entries) {
if (!entry.isFile() || !entry.name.endsWith('.html')) continue;
const stem = entry.name.slice(0, -5).replace(/[^a-zA-Z0-9_]/g, '_');
out[`${keyPrefix}${stem}`] = resolve(dirPath, entry.name);
}
return out;
}
const apiExampleEntries = collectHtmlEntriesFromDir(resolve(root, 'apiExamples'), 'apiExample_');
const htmlEntries = {
main: resolve(root, 'index.html'),
cad: resolve(root, 'cad.html'),
viewer: resolve(root, 'viewer.html'),
about: resolve(root, 'about.html'),
featureDialogs: resolve(root, 'feature-dialog-capture.html'),
pmiDialogs: resolve(root, 'pmi-dialog-capture.html'),
assemblyConstraintDialogs: resolve(root, 'assembly-constraint-capture.html'),
test: resolve(root, 'test.html'),
...apiExampleEntries,
};
export default defineConfig(() => {
const input = { ...htmlEntries };
return {
// Explicitly set the public directory to ensure generated docs are included
publicDir: 'public',
resolve: {
alias: {
'#textToFace/fontUrlLoaders': resolve(root, 'src/features/textToFace/fontUrlLoaders.vite.js'),
},
},
esbuild: {
keepNames: true,
},
// allow the tunneled host to access the dev server
server: {
allowedHosts: true,
cors: true,
},
build: {
minify: 'esbuild',
terserOptions: {
keep_fnames: true,
},
rollupOptions: {
input,
},
},
};
});