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(css): fix directory index import in sass modern api #17960

Merged
merged 4 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(css): fix directory index import in sass modern
  • Loading branch information
hi-ogawa committed Aug 28, 2024
commit 5513b7b09c87ad112025c92f5a057aab9a567483
5 changes: 1 addition & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,10 +1097,7 @@ function createCSSResolvers(config: ResolvedConfig): CSSAtImportResolvers {
sassResolve = async (...args) => {
const id = args[0]
if (id.startsWith('file://')) {
const fileUrl = new URL(id)
if (fs.existsSync(fileUrl)) {
return fileURLToPath(fileUrl)
}
args[0] = fileURLToPath(id)
}
return resolver(...args)
}
Expand Down
1 change: 1 addition & 0 deletions playground/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h1>CSS</h1>
<p class="sass-file-absolute">
@import "file:///xxx/absolute-path.scss" should be orange
</p>
<p class="sass-dir-index">@import "./dir" should be orange</p>

<p class="less">Less: This should be blue</p>
<p class="less-at-import">
Expand Down
1 change: 1 addition & 0 deletions playground/css/sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import '=/pkg-dep'; // package w/out sass field
@import '=/weapp.wxss'; // wxss file
@import 'virtual-file-absolute';
@import '=/scss-dir/main.scss'; // "./dir" reference from vite custom importer

.sass {
/* injected via vite.config.js */
Expand Down
3 changes: 3 additions & 0 deletions playground/css/scss-dir/dir/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.sass-dir-index {
color: orange;
}
1 change: 1 addition & 0 deletions playground/css/scss-dir/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './dir';