-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix(css): vite can't handle images in css correctly #7186
Conversation
…fter user-defined plugin The `vite-url-rewrite`plugin uses the input.file property to replace the url and put it in the last execution of postcssPlugins. The problem now is that some postcss plugins that users are currently using may make the input.file property disappear, resulting in vite not being able to handle the url correctly and packaging the result successfully. For example https://github.com/saionjisekai/px2rem-postcss/blob/1edc6763ad2fe8288ac6a8bda482319f006d8bb6/lib/index.js#L15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just chiming in that the issue seems clear and the fix seems reasonable. Patak mentioned this issue to me, which is why I’m leaving this review.
Thanks, keep learning from you guys |
Shouldn't this be fixed in export interface ProcessOptions {
/**
* The path of the CSS source file. You should always set `from`,
* because it is used in source map generation and syntax error messages.
*/
from?: string
/**
* Source map options
*/
map?: SourceMapOptions | boolean
}
|
Thanks for doing a review @jonathantneal, @bluwy's comment is in line with what I'm also worried about in this PR. I imagine a plugin injecting a URL or modifying it isn't uncommon, no? |
it works, thanks a lot. And I have some other ideas
All in all, I think that as long as In the end, this is actually a relatively small issue, thank you for your attention |
@wkstudy let's close this PR in favor of #8183. Please get back to us in case |
Description
The scene where the problem occurs during the following demo:
click me
npm run build
, vite prompts that the package is successful but the images in the css are not processednpm run build
again, the packaging is normalAdditional context
The reason for the problem is
vite-url-plugin
is executed after the user-defined componentvite-url-plugin
relies on theinput.file
property to change the resource pathinput.file
must have opts to generate, otherwise it will disappearpostcss-px2rem-exclude
plugin is called in my demo, and the postcss.parse method is called here, but the opts object is not passed, causing the subsequent css astobj to lose the input.file attributeWhat is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).