Skip to content

Commit 800e5d2

Browse files
committed
feat(build): set relative asset URLs and simplify asset file naming in Vite config
1 parent 0a9b8cb commit 800e5d2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

vite.config.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { defineConfig } from 'vite';
22

33
export default defineConfig({
4+
// Ensure asset URLs are relative to the built module (not absolute at site root)
5+
base: './',
46
build: {
57
lib: {
68
entry: 'src/index.js',
@@ -10,14 +12,9 @@ export default defineConfig({
1012
},
1113
rollupOptions: {
1214
output: {
13-
// Do NOT override entryFileNames so Vite uses lib.fileName for the entry
14-
// Worker and other assets will still be emitted under assets/
15-
assetFileNames: (assetInfo) => {
16-
if (assetInfo.name && assetInfo.name.includes('worker')) {
17-
return 'assets/[name]-[hash][extname]';
18-
}
19-
return 'assets/[name]-[hash][extname]';
20-
},
15+
// Keep assets under assets/; relative path is enforced by base: './'
16+
assetFileNames: 'assets/[name]-[hash][extname]',
17+
// Let Vite/rollup choose relative paths tied to the lib entry; no need to force chunks dirs
2118
},
2219
},
2320
sourcemap: true,

0 commit comments

Comments
 (0)