From e7453fd24e5f53930704294021ff234e719566b7 Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Tue, 30 Aug 2022 20:22:40 +0900 Subject: [PATCH 1/3] fix(css): remove css-post plugin sourcemap --- packages/vite/src/node/plugins/css.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 4dc3aa7f158587..aacd6cd0ccf732 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -380,7 +380,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { const cssContent = await getContentWithSourcemap(css) const devBase = config.base - return [ + const code = [ `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify( path.posix.join(devBase, CLIENT_PUBLIC_PATH) )}`, @@ -394,6 +394,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { }`, `import.meta.hot.prune(() => __vite__removeStyle(__vite__id))` ].join('\n') + return { code, map: { mappings: '' } } } // build CSS handling ---------------------------------------------------- From 4da0a6a73d74530c9d4e788e88b2f449ab73d840 Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Tue, 30 Aug 2022 20:32:33 +0900 Subject: [PATCH 2/3] test(css): add test --- playground/css-sourcemap/__tests__/css-sourcemap.spec.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts index cee31201cb2f6f..97d12213371c28 100644 --- a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts +++ b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts @@ -90,6 +90,15 @@ describe.runIf(isServe)('serve', () => { `) }) + test.runIf(isServe)('linked css with import', async () => { + const res = await page.request.get( + new URL('./linked-with-import.css', page.url()).href + ) + const content = await res.text() + const lines = content.trim().split('\n') + expect(lines[lines.length - 1]).not.toMatch(/^\/\/#/) + }) + test('imported css', async () => { const css = await getStyleTagContentIncluding('.imported ') const map = extractSourcemap(css) From e47ba57050b02defa607096437eaf7884b0959e1 Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Tue, 30 Aug 2022 21:09:28 +0900 Subject: [PATCH 3/3] test(css): fix test title --- .../__tests__/css-sourcemap.spec.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts index 97d12213371c28..d7e9a5e8ecd71d 100644 --- a/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts +++ b/playground/css-sourcemap/__tests__/css-sourcemap.spec.ts @@ -90,14 +90,17 @@ describe.runIf(isServe)('serve', () => { `) }) - test.runIf(isServe)('linked css with import', async () => { - const res = await page.request.get( - new URL('./linked-with-import.css', page.url()).href - ) - const content = await res.text() - const lines = content.trim().split('\n') - expect(lines[lines.length - 1]).not.toMatch(/^\/\/#/) - }) + test.runIf(isServe)( + 'js .css request does not include sourcemap', + async () => { + const res = await page.request.get( + new URL('./linked-with-import.css', page.url()).href + ) + const content = await res.text() + const lines = content.trim().split('\n') + expect(lines[lines.length - 1]).not.toMatch(/^\/\/#/) + } + ) test('imported css', async () => { const css = await getStyleTagContentIncluding('.imported ')