You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Astro we have had to write our own CSS plugin, due to the fact that the internal vite:css-post plugin has private state that only the HTML plugin knows about.
As such, we have had to solve most of the same problems that vite:css-post solves. One problem we cannot solve, however, is replacing VITE_ASSET_hash markers that the Asset plugin adds.
Suggested solution
One idea is to expose a function from the Asset plugin that replaces all VITE_ASSET markers, like:
// absolute base or relative base but inlined (injected as style tag into
// index.html) use the base as-is
returnconfig.base+filename
}else{
// relative base + extracted CSS - asset file will be in the same dir
return`./${path.posix.basename(filename)}`
}
})
Alternative
No response
Additional context
The coupling of HTML, CSS, and Asset plugins has made it difficult for us to use any of them, because they each rely on private state of the other. This means that if you try and replace one, it's difficult to keep the others.
Clear and concise description of the problem
In Astro we have had to write our own CSS plugin, due to the fact that the internal vite:css-post plugin has private state that only the HTML plugin knows about.
As such, we have had to solve most of the same problems that vite:css-post solves. One problem we cannot solve, however, is replacing
VITE_ASSET_hash
markers that the Asset plugin adds.Suggested solution
One idea is to expose a function from the Asset plugin that replaces all VITE_ASSET markers, like:
Or alternatively, expose
getAssetFilename
andassetUrlRE
so that they can be used in the same way that the CSS plugin does:vite/packages/vite/src/node/plugins/css.ts
Lines 391 to 402 in e6495f0
Alternative
No response
Additional context
The coupling of HTML, CSS, and Asset plugins has made it difficult for us to use any of them, because they each rely on private state of the other. This means that if you try and replace one, it's difficult to keep the others.
Validations
The text was updated successfully, but these errors were encountered: