diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 43bb7ad20df3de..8615ba0cf89d22 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -3195,7 +3195,6 @@ async function compileLightningCSS( css = css.replace(dep.placeholder, () => dep.url) break } - deps.add(dep.url) if (urlReplacer) { const replaceUrl = await urlReplacer( dep.url, diff --git a/playground/css-lightningcss/__tests__/css-lightningcss.spec.ts b/playground/css-lightningcss/__tests__/css-lightningcss.spec.ts index 6c995866a4bf00..0cfa1c7f9c05a9 100644 --- a/playground/css-lightningcss/__tests__/css-lightningcss.spec.ts +++ b/playground/css-lightningcss/__tests__/css-lightningcss.spec.ts @@ -82,3 +82,8 @@ test('nested css with relative asset', async () => { isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`, ) }) + +test('aliased asset', async () => { + const bg = await getBg('.css-url-aliased') + expect(bg).toMatch('data:image/svg+xml,') +}) diff --git a/playground/css-lightningcss/css-url.css b/playground/css-lightningcss/css-url.css new file mode 100644 index 00000000000000..2694e5f5136fec --- /dev/null +++ b/playground/css-lightningcss/css-url.css @@ -0,0 +1,4 @@ +.css-url-aliased { + background: url('@/fragment.svg'); + background-size: 10px; +} diff --git a/playground/css-lightningcss/index.html b/playground/css-lightningcss/index.html index 1dacab8f5133de..e2ee95e640e2bd 100644 --- a/playground/css-lightningcss/index.html +++ b/playground/css-lightningcss/index.html @@ -29,6 +29,10 @@
Assets relative to nested CSS
+ +