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

404 - Storybook cannot find components #169

Closed
Miguel-Bento-Github opened this issue Dec 1, 2021 · 5 comments
Closed

404 - Storybook cannot find components #169

Miguel-Bento-Github opened this issue Dec 1, 2021 · 5 comments

Comments

@Miguel-Bento-Github
Copy link

Description
Dev server works with the exact same config but Storybook seems to struggle.

Strange log as I don't use JSX or TSX

Plugin: vite:import-analysis
16:13:41 [vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
  Plugin: vite:import-analysis

and the browser console logs 404

GET http://localhost:6006/src/stories/BasicHeader.vue?vue&type=div&index=0&lang.div net::ERR_ABORTED 404 (Not Found)

To Reproduce
Please create a reproduction by running yarn && yarn storybook
Repo can be found at https://github.com/Miguel-Bento-Github/vite-vue-ts-storybook

Environment Info:

  System:
    OS: macOS 12.0.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 16.9.1 - /usr/local/bin/node
    Yarn: 1.22.15 - /opt/homebrew/bin/yarn
    npm: 7.21.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 96.0.4664.55
    Firefox: 94.0.2
    Safari: 15.1
  npmPackages:
    @storybook/addon-a11y: ^6.4.3 => 6.4.3 
    @storybook/addon-actions: ^6.4.3 => 6.4.3 
    @storybook/addon-essentials: ^6.4.3 => 6.4.3 
    @storybook/addon-links: ^6.4.3 => 6.4.3 
    @storybook/vue3: ^6.4.3 => 6.4.3 

Help is appreciated in advance.

@IanVS
Copy link
Member

IanVS commented Dec 1, 2021

It looks like your viteFinal is not quite right. You can remove the vue() plugin because the storybook builder already includes it and you'll end up with a duplicate, and you need to specify options to the vueI18n plugin:

diff --git a/.storybook/main.js b/.storybook/main.js
index f388ad7..6a16dfb 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -33,7 +33,14 @@ module.exports = {

     return mergeConfig(previousConfig, {
       ...config,
-      plugins: [vue(), vueI18n(), eslintPlugin()],
+      plugins: [
+        vueI18n({
+          include: path.resolve(__dirname, "../src/locales/**"),
+          compositionOnly: false,
+          runtimeOnly: false,
+        }),
+        eslintPlugin()
+      ],
     });
   },
 };

When I make that change, storybook builds correctly. Let me know if you still have any issues though.

@IanVS IanVS closed this as completed Dec 1, 2021
@Miguel-Bento-Github
Copy link
Author

@IanVS Thanks for the help, the issue left here is that I cannot build. Were you able to run yarn build?
I've made changes to the repo but the config is the same.

src/stories/Page.vue:75:15
error TS2322: Type '{ class: string; }' is not assignable to type  DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'.  
Property 'class' does not exist on type 
'DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>'. 
Did you mean 'className'?
<span class="tip">Tip</span>

I see this issue appearing at vuejs/core#1033 (comment)

Thanks in advance!

@IanVS
Copy link
Member

IanVS commented Dec 7, 2021

I was able to successfully yarn build-storybook. Any errors that you might get from yarn build would not be associated with this project, I think.

@Miguel-Bento-Github
Copy link
Author

@IanVS do you think it's related to this storybookjs/storybook#16630?
Seems like a storybook issue with a jsx parser or something like that. Should I open another issue at storybook?

@IanVS
Copy link
Member

IanVS commented Dec 8, 2021

It does look like that's what you're hitting. I don't think another issue would help, since there's already a PR open. It's probably best to give it a little time, or try to find a workaround to remove the types or ignore the errors for now until it is fixed.

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

No branches or pull requests

2 participants