Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Vite Pre-transform error: Failed to load url /sb-preview/runtime.js #25256

Closed
Hecatron opened this issue Dec 18, 2023 · 3 comments · Fixed by #25329
Closed

[Bug]: Vite Pre-transform error: Failed to load url /sb-preview/runtime.js #25256

Hecatron opened this issue Dec 18, 2023 · 3 comments · Fixed by #25329

Comments

@Hecatron
Copy link

Hecatron commented Dec 18, 2023

Describe the bug

When running storybook via vuejs, currently the following shows up in the console

12:55:22 [vite] Pre-transform error: Failed to load url /sb-preview/runtime.js (resolved id: /sb-preview/runtime.js). Does the file exist?

This is due to a new pre-transform feature of vite 5 I think
Currently storybook does already add the following in to the vite config as part of builder-vite

  build: {
    rollupOptions: {
      external: ['./sb-preview/runtime.js'],
    }
  }

What I think is also needed is the following

assetsInclude: ['/sb-preview/runtime.js'],

Fix pulled from the following

To Reproduce

pnpm create vue@latest
pnpm dlx storybook@latest init

System

Storybook Environment Info:

  System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Binaries:
    Node: 20.8.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.12.1 - ~\AppData\Local\pnpm\pnpm.CMD <----- active
  Browsers:
    Edge: Spartan (44.19041.3570.0), Chromium (120.0.2210.77)
tohosaku added a commit to tohosaku/storybook that referenced this issue Dec 18, 2023
@JReinhold JReinhold changed the title [Bug]: builder-vite assetsInclude /sb-preview/runtime.js [Bug]: Vite Pre-transform error: Failed to load url /sb-preview/runtime.js Dec 20, 2023
@vanessayuenn vanessayuenn moved this to Ready for work in Core Team Projects Dec 21, 2023
@ErickPetru
Copy link

ErickPetru commented Dec 21, 2023

I was facing this error on Storybook 7.6, after upgrading to Vite 5.
I confirm that assetsInclude: ['/sb-preview/runtime.js'] added to .storybook/vite.config.ts solved it.

@dev-madhurendra
Copy link

dev-madhurendra commented Dec 22, 2023

Hi @ErickPetru
I am not able to solve this issue by adding assetsInclude: ['/sb-preview/runtime.js'] to vite.config.ts

here is my folder structure
Screenshot from 2023-12-22 15-40-46

Error Details

[vite] Pre-transform error: Failed to load url /sb-preview/runtime.js (resolved id: /sb-preview/runtime.js). Does the file exist?

@ErickPetru
Copy link

@dev-madhurendra, I don't know if this can be the reason...
But I have a vite.config.ts exclusively for my .storybook folder needs:

VS Code open showing .storybook/main.ts and .storybook/vite.config.ts files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants