histoire
histoire copied to clipboard
Import error when using vite base path relative
Describe the bug
Hello, thanks for building histoire, love it!
When deploying histoire under a nested public path I set base to empty string https://vitejs.dev/config/shared-options.html#base
// histoire.config.ts
export default defineConfig({
vite: {
base: "",
},
but some ressources are requesting
/story/__sandbox.html
which doesn't exist in my dist
folder
resulting in this error:
Workaround
Creating the folder story
manually and copying in it the content of assets
fix my issue
# fix-build.sh
mkdir dist/story &&
cp dist/__sandbox.html dist/story/__sandbox.html &&
cp -R dist/assets dist/story/assets
I'm doing that for building:
npm run build:story && source fix-build.sh
Reproduction
https://stackblitz.com/edit/histoire-vue3-starter-a7mlkp?file=vite.config.ts
- build and preview the app
- open the base button story
System Info
/
Used Package Manager
npm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [X] The provided reproduction is a minimal reproducible example of the bug.
My base
is set to an empty string. I'm deploying to GitLab pages where url is of the following structure: https://deepc.gitlab.io/path/to/project
Histoire root page opens up correctly but then I have links to each story as the following: /./story/src-stories-viewer-story-vue
which doesn't correspond to my project url path/to/project
. If I open a story the url becomes https://deepc.gitlab.io/story/src-stories-viewer-story-vue
and this is incorrect. Refreshing the page now results in error 404. Any way I can fix that?
Update: I switched to "hash" router mode and urls now look #/story/src-stories-viewer-story-vue
which fixes my issue. But I still don't understand where does /./
come from with "history" router mode.
additional ref: https://github.com/histoire-dev/histoire/issues/143
Histoire should now follow the base
from vite configuration. Please reopen if you still have the issue with latest versions of Histoire and Vite.
I came across this error (on v0.17.2) and originally thought it was the base config too. I was able to fix it by updating the routerMode
to hash
in histoire.config
.
I came across this error (on v0.17.2) and originally thought it was the base config too. I was able to fix it by updating the
routerMethod
tohash
inhistoire.config
.
I suppose you mean 'routerMode' => that indeed solved it for me thanks!
I came across this error (on v0.17.2) and originally thought it was the base config too. I was able to fix it by updating the
routerMethod
tohash
inhistoire.config
.I suppose you mean 'routerMode' => that indeed solved it for me thanks!
Apologies it is actually routerMode
not routerMethod
.