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

fix: resolve @import of the proxied <style> #7031

Merged
merged 7 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/playground/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ <h3 class="import-css">@import</h3>
@import url('./css/import.css');
</style>

<h3 class="foo-public">
@import CSS from publicDir should load (this should be red)
</h3>
<style>
@import '/foo.css';
</style>

<script type="module">
import './css/fonts.css'
import './css/css-url.css'
Expand Down
3 changes: 3 additions & 0 deletions packages/playground/assets/static/foo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.foo-public {
color: red;
}
5 changes: 5 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,14 @@ async function compileCSS(
postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : []

if (needInlineImport) {
const isHTMLProxy = htmlProxyRE.test(id)
postcssPlugins.unshift(
(await import('postcss-import')).default({
async resolve(id, basedir) {
const publicFile = checkPublicFile(id, config)
if (isHTMLProxy && publicFile) {
return publicFile
}
const resolved = await atImportResolvers.css(
id,
path.join(basedir, '*')
Expand Down