fix storybook build

This commit is contained in:
Gauthier Roebroeck 2025-10-20 16:20:18 +08:00
parent 8e0620bb68
commit 8dacf906fa

View file

@ -22,7 +22,7 @@ const dirname =
typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url)) typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url))
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig(({ mode }) => ({
plugins: [ plugins: [
VueRouter({ VueRouter({
dts: 'src/typed-router.d.ts', dts: 'src/typed-router.d.ts',
@ -82,6 +82,9 @@ export default defineConfig({
port: 3000, port: 3000,
}, },
base: '/', base: '/',
// use 'prod' when building the app because storybook always use 'production' and cannot be configured.
// if renderBuiltUrl is used, Storybook doesn't work
...(mode === 'prod' && {
// support for the runtime base url (depending on the server.servlet.context-path) // support for the runtime base url (depending on the server.servlet.context-path)
// window.buildUrl is a function defined in index.html that dynamically provides the path // window.buildUrl is a function defined in index.html that dynamically provides the path
// it only works within js files though // it only works within js files though
@ -92,6 +95,7 @@ export default defineConfig({
else return { relative: true } else return { relative: true }
}, },
}, },
}),
optimizeDeps: { optimizeDeps: {
exclude: ['vuetify'], exclude: ['vuetify'],
}, },
@ -136,4 +140,4 @@ export default defineConfig({
}, },
], ],
}, },
}) }))