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

Plugin legacy skip emit assets #7422

Closed
7 tasks done
marco-prontera opened this issue Mar 23, 2022 · 5 comments
Closed
7 tasks done

Plugin legacy skip emit assets #7422

marco-prontera opened this issue Mar 23, 2022 · 5 comments

Comments

@marco-prontera
Copy link

Describe the bug

Hi guys, the latest version of the legacy plugin, no longer issues assets. This does not allow some plugins I use to apply logic even to the generated legacy bundle.

The line is this:
opts.__vite_skip_asset_emit__ = true

I think it is more appropriate to give the possibility to decide by means of a parameter. Obviously, you can set it to true by default in order to skip.

That would be great, thank you in advance, and thank you for your work ❤️.

Reproduction

All

System Info

All

Used Package Manager

npm

Logs

No logs

Validations

@bluwy
Copy link
Member

bluwy commented Mar 27, 2022

Related: #6584. That PR fixes some issues, which seems to conflict with this feature request. Can you further elaborate your use case and provide some examples of it?

@marco-prontera
Copy link
Author

@bluwy
Essentially the use case is the following: When I use my plugin for Vite to inject the CSS generated by the JS, I need also to inject the same CSS into the legacy bundle generated. But, the legacy code generation happens before the standard flow of Vite, so I don't have the possibility to get the CSS generated and put it inside the legacy bundle.

Now I leave you the link to the plugin here. You can try it and see that for the legacy bundle the CSS is empty. This can be fixed by generating the legacy bundle after the standard flow or giving the possibility through a param to choose if I need the CSS in the chunking phase during the legacy generation.

Thanks
https://github.com/Marco-Prontera/vite-plugin-css-injected-by-js

@marco-prontera
Copy link
Author

@bluwy I created a PR to cover those requirements. If you can see it, is very simple and it'a implementation is covered by a documentation that tells the purpose.

Thanks in advance

@bluwy
Copy link
Member

bluwy commented Apr 21, 2022

Thanks for providing your usecase. I tested this on stackblitz and it seems to be working fine in a different way. It looks like Vite already inlines css in legacy with this code

// legacy build, inline css
chunkCSS = await processChunkCSS(chunkCSS, {
inlined: true,
minify: true
})
const style = `__vite_style__`
const injectCode =
`var ${style} = document.createElement('style');` +
`${style}.innerHTML = ${JSON.stringify(chunkCSS)};` +
`document.head.appendChild(${style});`

so maybe it's not needed for the plugin to handle it?

@marco-prontera
Copy link
Author

Thanks, I knew about the configuration through Vite, but in this case, I cannot choose the details.
I would also need to inject code that comes from "dynamic" sources, I have a custom version that allows me to optimize a product through the build phase, taking some style and putting it directly in the build (even legacy build).
But for now, I have to use a custom (local) version of the legacy plugin with the modification proposed in PR.

@marco-prontera marco-prontera closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants