Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteae00b5

Browse files
hi-ogawasapphi-red
authored andcommitted
fix(css): fix lightningcss dep url resolution with custom root (#18125)
1 parentc5d48d5 commiteae00b5

File tree

9 files changed

+52
-1
lines changed

9 files changed

+52
-1
lines changed

‎packages/vite/src/node/plugins/css.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,10 @@ async function compileLightningCSS(
30303030
}
30313031
deps.add(dep.url)
30323032
if(urlReplacer){
3033-
constreplaceUrl=awaiturlReplacer(dep.url,dep.loc.filePath)
3033+
constreplaceUrl=awaiturlReplacer(
3034+
dep.url,
3035+
toAbsolute(dep.loc.filePath),
3036+
)
30343037
css=css.replace(dep.placeholder,()=>replaceUrl)
30353038
}else{
30363039
css=css.replace(dep.placeholder,()=>dep.url)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import{expect,test}from'vitest'
2+
import{getBg,isBuild,page,viteTestUrl}from'~utils'
3+
4+
test('url dependency',async()=>{
5+
constcss=awaitpage.$('.url-dep')
6+
expect(awaitgetBg(css)).toMatch(
7+
isBuild ?/ok-[-\w]+\.png/ :`${viteTestUrl}/ok.png`,
8+
)
9+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name":"@vitejs/test-css-lightningcss-root",
3+
"private":true,
4+
"type":"module",
5+
"scripts": {
6+
"dev":"vite",
7+
"build":"vite build",
8+
"debug":"node --inspect-brk ../../packages/vite/bin/vite",
9+
"preview":"vite preview"
10+
},
11+
"devDependencies": {
12+
"lightningcss":"^1.27.0"
13+
}
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>url() dependency</p>
2+
<divclass="url-dep"></div>
3+
<scripttype="module"src="./main.js"></script>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import'./url-dep.css'
4.87 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.url-dep {
2+
background-image:url('./ok.png');
3+
background-size: cover;
4+
width:50px;
5+
height:50px;
6+
border:1px solid black;
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import{defineConfig}from'vite'
2+
3+
exportdefaultdefineConfig({
4+
root:'root',
5+
css:{
6+
transformer:'lightningcss',
7+
},
8+
})

‎pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp