From 8ab0dbef5971b73c218cf17f10a40aa287e90c1d Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Sep 2024 11:52:18 +0900 Subject: [PATCH 1/8] fix(css): fix lightningcss dep url resolution with custom root --- packages/vite/src/node/plugins/css.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 390804543ce9e3..11094160bf27a6 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -3094,7 +3094,10 @@ async function compileLightningCSS( } deps.add(dep.url) if (urlReplacer) { - const replaceUrl = await urlReplacer(dep.url, dep.loc.filePath) + const replaceUrl = await urlReplacer( + dep.url, + toAbsolute(dep.loc.filePath), + ) css = css.replace(dep.placeholder, () => replaceUrl) } else { css = css.replace(dep.placeholder, () => dep.url) From dceaaf30085898dd2d07555c7046d4a3b56f46be Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Sep 2024 12:32:10 +0900 Subject: [PATCH 2/8] test: add test --- .../css-lightningcss/__tests__/root/root.spec.ts | 9 +++++++++ playground/css-lightningcss/package.json | 2 ++ playground/css-lightningcss/root/index.html | 3 +++ playground/css-lightningcss/root/main.js | 1 + playground/css-lightningcss/root/ok.png | Bin 0 -> 4986 bytes playground/css-lightningcss/root/url-dep.css | 7 +++++++ playground/css-lightningcss/vite.config-root.js | 7 +++++++ 7 files changed, 29 insertions(+) create mode 100644 playground/css-lightningcss/__tests__/root/root.spec.ts create mode 100644 playground/css-lightningcss/root/index.html create mode 100644 playground/css-lightningcss/root/main.js create mode 100644 playground/css-lightningcss/root/ok.png create mode 100644 playground/css-lightningcss/root/url-dep.css create mode 100644 playground/css-lightningcss/vite.config-root.js diff --git a/playground/css-lightningcss/__tests__/root/root.spec.ts b/playground/css-lightningcss/__tests__/root/root.spec.ts new file mode 100644 index 00000000000000..786d17f124ab87 --- /dev/null +++ b/playground/css-lightningcss/__tests__/root/root.spec.ts @@ -0,0 +1,9 @@ +import { expect, test } from 'vitest' +import { getBg, isBuild, page, viteTestUrl } from '~utils' + +test('url dependency', async () => { + const css = await page.$('.url-dep') + expect(await getBg(css)).toMatch( + isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`, + ) +}) diff --git a/playground/css-lightningcss/package.json b/playground/css-lightningcss/package.json index aefbf1582d9686..18cb021c9fed67 100644 --- a/playground/css-lightningcss/package.json +++ b/playground/css-lightningcss/package.json @@ -5,6 +5,8 @@ "scripts": { "dev": "vite", "build": "vite build", + "dev:root": "vite --config ./vite.config-root.js dev", + "build:root": "vite --config ./vite.config-root.js build", "debug": "node --inspect-brk ../../packages/vite/bin/vite", "preview": "vite preview" }, diff --git a/playground/css-lightningcss/root/index.html b/playground/css-lightningcss/root/index.html new file mode 100644 index 00000000000000..df2820bbe74c59 --- /dev/null +++ b/playground/css-lightningcss/root/index.html @@ -0,0 +1,3 @@ +

url() dependency

+
+ diff --git a/playground/css-lightningcss/root/main.js b/playground/css-lightningcss/root/main.js new file mode 100644 index 00000000000000..fe93503f500dd8 --- /dev/null +++ b/playground/css-lightningcss/root/main.js @@ -0,0 +1 @@ +import './url-dep.css' diff --git a/playground/css-lightningcss/root/ok.png b/playground/css-lightningcss/root/ok.png new file mode 100644 index 0000000000000000000000000000000000000000..a8d1e52510c41ceeaf3515ee2f594a82557d1685 GIT binary patch literal 4986 zcmZ`*2RK|?*B+e_JxHPrqC^`dI%D+CL?i|g27@8m=!PJK=%R!nQKA!~B)aHPqD6@= zdX1Xs?IXGWz4!UQ|3BwBXT4{y^{#jAwa>H935DsXk^yf40RRA*x|)*SrIo+D1c?bR z?>eFMtN;LT2BoM7Q&&_3!O)IYs3%AOKrJ*Okx2i(;Vu6y%xWZ*nhnJ9i&KruKfWK2 zyFN@q4VQ$YH7MOol~C15pOUIc*gumE7!~CoK~QR@T#8_ck(W0lA{Eo$$I(o}%GP4` z{gywSytz0#03S?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t_XHc+yL5Z^}uFE%vn zHD_V5NyylkAvO?1gV65Lotd3|o-0Q|;j#VmXF@($H!mlL&@?AELqn+i`TL@xmI`4k z2lzop7xdiL_pI+m;uEW9&v0kSmIUODjY&VJ%7yIjlXD9Q1XNVG53!@(q@}g2*ko!o zJJst~!}YJJtDC|^%7VTPf8&#A);uj*sJ~6zDruM_EL;v^XAgJbL)XSTu`zeBBq%?U z2N_mgK)ENYf0DW>E=AYXF@hEg_+pL8V?hgS>|&g^9L_!QaPdw#%(0FvX|hg51=O(+ zT}uN08)f#XS#M%#R#yi*tImpx3PaW|qQ(YlzSz5T;iHzjk)*PuF-%h(9o+mRG&D3N zC4$SYoje;`%9V)(&Ed=+%H~~oh>%2Q4M+3xX6M9L8{i|vF824%=R&;w2fP57lKV)S b37?V{t|cgkE9S{uec08Nb(D$~%%1%R{RRHc literal 0 HcmV?d00001 diff --git a/playground/css-lightningcss/root/url-dep.css b/playground/css-lightningcss/root/url-dep.css new file mode 100644 index 00000000000000..f56470afc0bb51 --- /dev/null +++ b/playground/css-lightningcss/root/url-dep.css @@ -0,0 +1,7 @@ +.url-dep { + background-image: url('./ok.png'); + background-size: cover; + width: 50px; + height: 50px; + border: 1px solid black; +} diff --git a/playground/css-lightningcss/vite.config-root.js b/playground/css-lightningcss/vite.config-root.js new file mode 100644 index 00000000000000..2b3aa3cfe8e6a0 --- /dev/null +++ b/playground/css-lightningcss/vite.config-root.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import baseConfig from './vite.config' + +export default defineConfig({ + ...baseConfig, + root: 'root', +}) From 27cd06710155bbbb7471de69038a6a9ece69e00e Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Sep 2024 13:11:18 +0900 Subject: [PATCH 3/8] test: move test --- .../__tests__/css-lightningcss-root.spec.ts | 9 +++++++++ playground/css-lightningcss-root/package.json | 14 ++++++++++++++ playground/css-lightningcss-root/root/index.html | 3 +++ playground/css-lightningcss-root/root/main.js | 1 + playground/css-lightningcss-root/root/ok.png | Bin 0 -> 4986 bytes .../css-lightningcss-root/root/url-dep.css | 7 +++++++ playground/css-lightningcss-root/vite.config.js | 8 ++++++++ 7 files changed, 42 insertions(+) create mode 100644 playground/css-lightningcss-root/__tests__/css-lightningcss-root.spec.ts create mode 100644 playground/css-lightningcss-root/package.json create mode 100644 playground/css-lightningcss-root/root/index.html create mode 100644 playground/css-lightningcss-root/root/main.js create mode 100644 playground/css-lightningcss-root/root/ok.png create mode 100644 playground/css-lightningcss-root/root/url-dep.css create mode 100644 playground/css-lightningcss-root/vite.config.js diff --git a/playground/css-lightningcss-root/__tests__/css-lightningcss-root.spec.ts b/playground/css-lightningcss-root/__tests__/css-lightningcss-root.spec.ts new file mode 100644 index 00000000000000..786d17f124ab87 --- /dev/null +++ b/playground/css-lightningcss-root/__tests__/css-lightningcss-root.spec.ts @@ -0,0 +1,9 @@ +import { expect, test } from 'vitest' +import { getBg, isBuild, page, viteTestUrl } from '~utils' + +test('url dependency', async () => { + const css = await page.$('.url-dep') + expect(await getBg(css)).toMatch( + isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`, + ) +}) diff --git a/playground/css-lightningcss-root/package.json b/playground/css-lightningcss-root/package.json new file mode 100644 index 00000000000000..5f0aa17122a1ad --- /dev/null +++ b/playground/css-lightningcss-root/package.json @@ -0,0 +1,14 @@ +{ + "name": "@vitejs/test-css-lightningcss-root", + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "debug": "node --inspect-brk ../../packages/vite/bin/vite", + "preview": "vite preview" + }, + "devDependencies": { + "lightningcss": "^1.26.0" + } +} diff --git a/playground/css-lightningcss-root/root/index.html b/playground/css-lightningcss-root/root/index.html new file mode 100644 index 00000000000000..df2820bbe74c59 --- /dev/null +++ b/playground/css-lightningcss-root/root/index.html @@ -0,0 +1,3 @@ +

url() dependency

+
+ diff --git a/playground/css-lightningcss-root/root/main.js b/playground/css-lightningcss-root/root/main.js new file mode 100644 index 00000000000000..fe93503f500dd8 --- /dev/null +++ b/playground/css-lightningcss-root/root/main.js @@ -0,0 +1 @@ +import './url-dep.css' diff --git a/playground/css-lightningcss-root/root/ok.png b/playground/css-lightningcss-root/root/ok.png new file mode 100644 index 0000000000000000000000000000000000000000..a8d1e52510c41ceeaf3515ee2f594a82557d1685 GIT binary patch literal 4986 zcmZ`*2RK|?*B+e_JxHPrqC^`dI%D+CL?i|g27@8m=!PJK=%R!nQKA!~B)aHPqD6@= zdX1Xs?IXGWz4!UQ|3BwBXT4{y^{#jAwa>H935DsXk^yf40RRA*x|)*SrIo+D1c?bR z?>eFMtN;LT2BoM7Q&&_3!O)IYs3%AOKrJ*Okx2i(;Vu6y%xWZ*nhnJ9i&KruKfWK2 zyFN@q4VQ$YH7MOol~C15pOUIc*gumE7!~CoK~QR@T#8_ck(W0lA{Eo$$I(o}%GP4` z{gywSytz0#03S?ZdM^O!LEBja*Wk4NTIv;iY>g?j^l6RFdwA68IJmpt=64qLbl`Ae zsHN?BVO;}h`p(g-;i~t37w4wWIVro20MJlkF4Bclt)PjRoiK0$63<^MVudWxQnUR? ztoho_SWq+G{A;OB)6bG#&%PGWh~1-t5HsNTbN%!z(+6~jy+}=H(N#W;X`!rmN!&^u zWWfHTiGBy4nBBSQU3d38XJ&=bYo&>}Pz0!3=RB@&sNqoe;qmg0UV@C_NYIRL8yZCj zKDd}nzTn5+49ma4*#Qc-44~@hR@&cs?ESDLmZS5hLN1&ysU*$pC7Ymk*bzD{=nmbs zPhf(b$kKBy=djVV!e4Pck;lVEfh(vYePen*(4_xexEL1)_4uNw7g9S@HCXq4M@ zoTDVHrmue)WDm@>_lft$vMFF2VAM0ROe3a-n4DAHy|C)8k7IB1pvaB7)zjzHy&rVF zUJHu{^p7}>a~h$*J^K$o$65v5*?4{vN26YbORrjtLGtyWT}wPB=`$%X#e9bJ6iU2X z0=-*8A4PbXeAZR z0kwH*@;Bs$eAF&xp*LP@J@yO0MgSi=-}Ir^h8{443rHS60vh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{~nM*yVCP_|+K4b!KLB z$dic+l{Nn~6Rv(AC z1FKTm+S}V%*C$6{`uey*iK-|21TA0l)Zn!b6Cd>K^JCW9zdDONx>MU-aB#R|I%m~eo6M=u^BIkm z)j>ayAomTE7{2gmxhQ+2kmf5zJ3HR0DsMBH-6mGnlP2pv2SGtW=ux>fyVIU6?ZVQc zqMx6fue;}F&=${^rluz5y(;0X9||qa2pgLh$)jUq^4{J&c?AV%wviuOw zl@44MJUqPcU-29<#^lxwU9BXcLz`{Qj`Z1|?oN)6kH?(#NRED*!n(hFC*idl{~>wO z-PTBIvWDZWRMtXRI8ffy)U>!qL&{JdvX-rHG@yA*_I1o}%g&6K7Of>-& zJPsz)BO@Xt`UuJhtx}x-~LVnovYU1icaewG;TPzZv)Jd+hNg@vGls}^HS%XRuS z^M|k4sqW=@pTZf}f$T7<^l6_Z8-4uI@o^YcwWgX5M6|&;Uxt_XHc+yL5Z^}uFE%vn zHD_V5NyylkAvO?1gV65Lotd3|o-0Q|;j#VmXF@($H!mlL&@?AELqn+i`TL@xmI`4k z2lzop7xdiL_pI+m;uEW9&v0kSmIUODjY&VJ%7yIjlXD9Q1XNVG53!@(q@}g2*ko!o zJJst~!}YJJtDC|^%7VTPf8&#A);uj*sJ~6zDruM_EL;v^XAgJbL)XSTu`zeBBq%?U z2N_mgK)ENYf0DW>E=AYXF@hEg_+pL8V?hgS>|&g^9L_!QaPdw#%(0FvX|hg51=O(+ zT}uN08)f#XS#M%#R#yi*tImpx3PaW|qQ(YlzSz5T;iHzjk)*PuF-%h(9o+mRG&D3N zC4$SYoje;`%9V)(&Ed=+%H~~oh>%2Q4M+3xX6M9L8{i|vF824%=R&;w2fP57lKV)S b37?V{t|cgkE9S{uec08Nb(D$~%%1%R{RRHc literal 0 HcmV?d00001 diff --git a/playground/css-lightningcss-root/root/url-dep.css b/playground/css-lightningcss-root/root/url-dep.css new file mode 100644 index 00000000000000..f56470afc0bb51 --- /dev/null +++ b/playground/css-lightningcss-root/root/url-dep.css @@ -0,0 +1,7 @@ +.url-dep { + background-image: url('./ok.png'); + background-size: cover; + width: 50px; + height: 50px; + border: 1px solid black; +} diff --git a/playground/css-lightningcss-root/vite.config.js b/playground/css-lightningcss-root/vite.config.js new file mode 100644 index 00000000000000..6e42d3e20e28be --- /dev/null +++ b/playground/css-lightningcss-root/vite.config.js @@ -0,0 +1,8 @@ +import { defineConfig } from 'vite' + +export default defineConfig({ + root: 'root', + css: { + transformer: 'lightningcss', + }, +}) From 486b664668bed53712526d9f8d8a68d22d513270 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Sep 2024 13:11:29 +0900 Subject: [PATCH 4/8] Revert "test: add test" This reverts commit dceaaf30085898dd2d07555c7046d4a3b56f46be. --- .../css-lightningcss/__tests__/root/root.spec.ts | 9 --------- playground/css-lightningcss/package.json | 2 -- playground/css-lightningcss/root/index.html | 3 --- playground/css-lightningcss/root/main.js | 1 - playground/css-lightningcss/root/ok.png | Bin 4986 -> 0 bytes playground/css-lightningcss/root/url-dep.css | 7 ------- playground/css-lightningcss/vite.config-root.js | 7 ------- 7 files changed, 29 deletions(-) delete mode 100644 playground/css-lightningcss/__tests__/root/root.spec.ts delete mode 100644 playground/css-lightningcss/root/index.html delete mode 100644 playground/css-lightningcss/root/main.js delete mode 100644 playground/css-lightningcss/root/ok.png delete mode 100644 playground/css-lightningcss/root/url-dep.css delete mode 100644 playground/css-lightningcss/vite.config-root.js diff --git a/playground/css-lightningcss/__tests__/root/root.spec.ts b/playground/css-lightningcss/__tests__/root/root.spec.ts deleted file mode 100644 index 786d17f124ab87..00000000000000 --- a/playground/css-lightningcss/__tests__/root/root.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { expect, test } from 'vitest' -import { getBg, isBuild, page, viteTestUrl } from '~utils' - -test('url dependency', async () => { - const css = await page.$('.url-dep') - expect(await getBg(css)).toMatch( - isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`, - ) -}) diff --git a/playground/css-lightningcss/package.json b/playground/css-lightningcss/package.json index 18cb021c9fed67..aefbf1582d9686 100644 --- a/playground/css-lightningcss/package.json +++ b/playground/css-lightningcss/package.json @@ -5,8 +5,6 @@ "scripts": { "dev": "vite", "build": "vite build", - "dev:root": "vite --config ./vite.config-root.js dev", - "build:root": "vite --config ./vite.config-root.js build", "debug": "node --inspect-brk ../../packages/vite/bin/vite", "preview": "vite preview" }, diff --git a/playground/css-lightningcss/root/index.html b/playground/css-lightningcss/root/index.html deleted file mode 100644 index df2820bbe74c59..00000000000000 --- a/playground/css-lightningcss/root/index.html +++ /dev/null @@ -1,3 +0,0 @@ -

url() dependency

-
- diff --git a/playground/css-lightningcss/root/main.js b/playground/css-lightningcss/root/main.js deleted file mode 100644 index fe93503f500dd8..00000000000000 --- a/playground/css-lightningcss/root/main.js +++ /dev/null @@ -1 +0,0 @@ -import './url-dep.css' diff --git a/playground/css-lightningcss/root/ok.png b/playground/css-lightningcss/root/ok.png deleted file mode 100644 index a8d1e52510c41ceeaf3515ee2f594a82557d1685..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4986 zcmZ`*2RK|?*B+e_JxHPrqC^`dI%D+CL?i|g27@8m=!PJK=%R!nQKA!~B)aHPqD6@= zdX1Xs?IXGWz4!UQ|3BwBXT4{y^{#jAwa>H935DsXk^yf40RRA*x|)*SrIo+D1c?bR z?>eFMtN;LT2BoM7Q&&_3!O)IYs3%AOKrJ*Okx2i(;Vu6y%xWZ*nhnJ9i&KruKfWK2 zyFN@q4VQ$YH7MOol~C15pOUIc*gumE7!~CoK~QR@T#8_ck(W0lA{Eo$$I(o}%GP4` z{gywSytz0#03S?ZdM^O!LEBja*Wk4NTIv;iY>g?j^l6RFdwA68IJmpt=64qLbl`Ae zsHN?BVO;}h`p(g-;i~t37w4wWIVro20MJlkF4Bclt)PjRoiK0$63<^MVudWxQnUR? ztoho_SWq+G{A;OB)6bG#&%PGWh~1-t5HsNTbN%!z(+6~jy+}=H(N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7VTPf8&#A);uj*sJ~6zDruM_EL;v^XAgJbL)XSTu`zeBBq%?U z2N_mgK)ENYf0DW>E=AYXF@hEg_+pL8V?hgS>|&g^9L_!QaPdw#%(0FvX|hg51=O(+ zT}uN08)f#XS#M%#R#yi*tImpx3PaW|qQ(YlzSz5T;iHzjk)*PuF-%h(9o+mRG&D3N zC4$SYoje;`%9V)(&Ed=+%H~~oh>%2Q4M+3xX6M9L8{i|vF824%=R&;w2fP57lKV)S b37?V{t|cgkE9S{uec08Nb(D$~%%1%R{RRHc diff --git a/playground/css-lightningcss/root/url-dep.css b/playground/css-lightningcss/root/url-dep.css deleted file mode 100644 index f56470afc0bb51..00000000000000 --- a/playground/css-lightningcss/root/url-dep.css +++ /dev/null @@ -1,7 +0,0 @@ -.url-dep { - background-image: url('./ok.png'); - background-size: cover; - width: 50px; - height: 50px; - border: 1px solid black; -} diff --git a/playground/css-lightningcss/vite.config-root.js b/playground/css-lightningcss/vite.config-root.js deleted file mode 100644 index 2b3aa3cfe8e6a0..00000000000000 --- a/playground/css-lightningcss/vite.config-root.js +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' -import baseConfig from './vite.config' - -export default defineConfig({ - ...baseConfig, - root: 'root', -}) From 4f36d35d9c394313dd36189aeeca41c04a0bce00 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Sep 2024 13:14:44 +0900 Subject: [PATCH 5/8] chore: fix lockfile --- pnpm-lock.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b111d84a83e100..1cd38823b0543c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -595,6 +595,12 @@ importers: specifier: ^1.26.0 version: 1.26.0 + playground/css-lightningcss-root: + devDependencies: + lightningcss: + specifier: ^1.26.0 + version: 1.26.0 + playground/css-no-codesplit: {} playground/css-sourcemap: From 6211911d68a4c8330bf666191d87a953bf2fc4fc Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:16:48 +0900 Subject: [PATCH 6/8] test: move root to dir root has a special meaning https://github.com/vitejs/vite/blob/993d45bf45400157e0a7bec91e038fc87d598dac/playground/vitestSetup.ts#L138-L140 --- .../css-lightningcss-root/{root => dir}/index.html | 0 .../css-lightningcss-root/{root => dir}/main.js | 0 .../css-lightningcss-root/{root => dir}/ok.png | Bin .../css-lightningcss-root/{root => dir}/url-dep.css | 0 playground/css-lightningcss-root/vite.config.js | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename playground/css-lightningcss-root/{root => dir}/index.html (100%) rename playground/css-lightningcss-root/{root => dir}/main.js (100%) rename playground/css-lightningcss-root/{root => dir}/ok.png (100%) rename playground/css-lightningcss-root/{root => dir}/url-dep.css (100%) diff --git a/playground/css-lightningcss-root/root/index.html b/playground/css-lightningcss-root/dir/index.html similarity index 100% rename from playground/css-lightningcss-root/root/index.html rename to playground/css-lightningcss-root/dir/index.html diff --git a/playground/css-lightningcss-root/root/main.js b/playground/css-lightningcss-root/dir/main.js similarity index 100% rename from playground/css-lightningcss-root/root/main.js rename to playground/css-lightningcss-root/dir/main.js diff --git a/playground/css-lightningcss-root/root/ok.png b/playground/css-lightningcss-root/dir/ok.png similarity index 100% rename from playground/css-lightningcss-root/root/ok.png rename to playground/css-lightningcss-root/dir/ok.png diff --git a/playground/css-lightningcss-root/root/url-dep.css b/playground/css-lightningcss-root/dir/url-dep.css similarity index 100% rename from playground/css-lightningcss-root/root/url-dep.css rename to playground/css-lightningcss-root/dir/url-dep.css diff --git a/playground/css-lightningcss-root/vite.config.js b/playground/css-lightningcss-root/vite.config.js index 6e42d3e20e28be..df968195a3f07e 100644 --- a/playground/css-lightningcss-root/vite.config.js +++ b/playground/css-lightningcss-root/vite.config.js @@ -1,7 +1,7 @@ import { defineConfig } from 'vite' export default defineConfig({ - root: 'root', + root: 'dir', css: { transformer: 'lightningcss', }, From ada8ab50048bf492d49f0f91296a718699b96236 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:20:12 +0900 Subject: [PATCH 7/8] chore: align lightningcss versions --- playground/css-lightningcss-root/package.json | 2 +- pnpm-lock.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/playground/css-lightningcss-root/package.json b/playground/css-lightningcss-root/package.json index 5f0aa17122a1ad..e1669e89b1a80d 100644 --- a/playground/css-lightningcss-root/package.json +++ b/playground/css-lightningcss-root/package.json @@ -9,6 +9,6 @@ "preview": "vite preview" }, "devDependencies": { - "lightningcss": "^1.26.0" + "lightningcss": "^1.27.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dff688be2bbbb8..946747d1791306 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -598,8 +598,8 @@ importers: playground/css-lightningcss-root: devDependencies: lightningcss: - specifier: ^1.26.0 - version: 1.26.0 + specifier: ^1.27.0 + version: 1.27.0 playground/css-no-codesplit: {} From 9ad8e3bfba4c1c707e22a9af68211621d159c204 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:33:08 +0900 Subject: [PATCH 8/8] Revert "test: move root to dir" This reverts commit 6211911d68a4c8330bf666191d87a953bf2fc4fc. --- .../css-lightningcss-root/{dir => root}/index.html | 0 .../css-lightningcss-root/{dir => root}/main.js | 0 .../css-lightningcss-root/{dir => root}/ok.png | Bin .../css-lightningcss-root/{dir => root}/url-dep.css | 0 playground/css-lightningcss-root/vite.config.js | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename playground/css-lightningcss-root/{dir => root}/index.html (100%) rename playground/css-lightningcss-root/{dir => root}/main.js (100%) rename playground/css-lightningcss-root/{dir => root}/ok.png (100%) rename playground/css-lightningcss-root/{dir => root}/url-dep.css (100%) diff --git a/playground/css-lightningcss-root/dir/index.html b/playground/css-lightningcss-root/root/index.html similarity index 100% rename from playground/css-lightningcss-root/dir/index.html rename to playground/css-lightningcss-root/root/index.html diff --git a/playground/css-lightningcss-root/dir/main.js b/playground/css-lightningcss-root/root/main.js similarity index 100% rename from playground/css-lightningcss-root/dir/main.js rename to playground/css-lightningcss-root/root/main.js diff --git a/playground/css-lightningcss-root/dir/ok.png b/playground/css-lightningcss-root/root/ok.png similarity index 100% rename from playground/css-lightningcss-root/dir/ok.png rename to playground/css-lightningcss-root/root/ok.png diff --git a/playground/css-lightningcss-root/dir/url-dep.css b/playground/css-lightningcss-root/root/url-dep.css similarity index 100% rename from playground/css-lightningcss-root/dir/url-dep.css rename to playground/css-lightningcss-root/root/url-dep.css diff --git a/playground/css-lightningcss-root/vite.config.js b/playground/css-lightningcss-root/vite.config.js index df968195a3f07e..6e42d3e20e28be 100644 --- a/playground/css-lightningcss-root/vite.config.js +++ b/playground/css-lightningcss-root/vite.config.js @@ -1,7 +1,7 @@ import { defineConfig } from 'vite' export default defineConfig({ - root: 'dir', + root: 'root', css: { transformer: 'lightningcss', },