-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[2.8.5] Invalid script being added to html #7124
Comments
I am following it 😊 |
hi @IanVS The index.html inline css will request the module script to load css, but I don't know why it load all the html. if (node.tag === 'style' && node.children.length) {
addInlineModule(node, 'css')
} in mine PR is only get the style node children 🥲 |
oh your |
Thanks for investigating, @poyoho ! I'm sorry, but I don't understand what the problem is, or what we should do to fix it. Could you please explain a little more? Thanks! |
my mean is why |
This has been working fine for us up until now... It's the way that we can create a virutal entry point, since there is no real |
😊 Good morning. I know how to resolve this problem. @IanVS you can add this code in the import { parse as parseUrl, URLSearchParams } from 'url'
function parseRequest(id: string): Record<string, string> | null {
const { search } = parseUrl(id)
if (!search) {
return null
}
return Object.fromEntries(new URLSearchParams(search.slice(1)))
}
function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): RequestHandler {
return async (req, res, next) => {
if (!req.url.match(/^\/iframe.html($|\?)/)) {
next();
return;
}
const query = parseRequest(req.url)!
if (query['html-proxy'] !== undefined) {
next();
return;
}
const indexHtml = fs.readFileSync(path.resolve(__dirname, '..', 'input', 'iframe.html'), 'utf-8');
const generated = await transformIframeHtml(indexHtml, options);
const transformed = await server.transformIndexHtml('/iframe.html', generated);
res.setHeader('Content-Type', 'text/html');
res.status(200).send(transformed);
};
} I test it will work 👻 |
Describe the bug
I updated my project to vite 2.8.5, and found that my storybook using
storybook-builder-vite
started to fail. I now see this in my browser console:And I see that two new scripts have been added to my root html that is served to the browser:
These are served by express with
text/html
, which causes the error.I did a git bisect, and traced the start of the error to #7052.
In the reproduction below (make sure you're on the
upgrade-vite-2.8.5
branch), runyarn install
, thencd examples/react
andyarn storybook
. When the browser opens, you'll see the console errors and an ugly block of text at the top of the page withNo Preview
in it.Reproduction
https://github.com/eirslett/storybook-builder-vite/tree/upgrade-vite-2.8.5
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: