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

iframe style tags are stripped by Vite 2.8.5 #266

Closed
justrhysism opened this issue Mar 1, 2022 · 3 comments · Fixed by #268
Closed

iframe style tags are stripped by Vite 2.8.5 #266

justrhysism opened this issue Mar 1, 2022 · 3 comments · Fixed by #268

Comments

@justrhysism
Copy link

When Vite 2.8.5 executes transformIndexHtml and internally runs "devHtmlHook", all the <style> are stripped from the iframe <head> resulting in Storybook's template code being exposed:

image

Have confirmed that this issue is new for 2.8.5 (downgrading to 2.8.4 doesn't exhibit this behaviour).

@IanVS
Copy link
Member

IanVS commented Mar 1, 2022

Thanks, I'm working with the vite folks to figure out what's going wrong. vitejs/vite#7124

@Dschungelabenteuer
Copy link
Member

https://github.com/eirslett/storybook-builder-vite/blob/main/packages/storybook-builder-vite/index.ts#L20

Now that Vite uses ?html-proxy to handle HMR for style tags in HTML files (vitejs/vite#7052 as you pointed out), it seems to match the regex here and therefore serve the whole iframe.html again instead of the vite-generated asset.

I've tried to tweak the condition into something silly like this:

if (req.url.match(/\?html-proxy/) || !req.url.match(/^\/iframe.html($|\?)/)) {
    next();
    return;
  }

This seems to work fine in my case but this requires additional checks with Storybook's query parameters.

@justrhysism
Copy link
Author

Have confirmed this issue is fixed for Vite 2.8.6.

Will close as there are other issues tracking the underlying problem. Thanks everyone!

IanVS pushed a commit that referenced this issue Mar 14, 2022
Fixes #266

See comment #266 (comment)

* Upgraded to Vite 2.8.5 to reproduce the issue
* Updated outdated CONTRIBUTING.md
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

Successfully merging a pull request may close this issue.

3 participants