Skip to content

Commit

Permalink
fix(css): remove css-post plugin sourcemap (#9914)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 30, 2022
1 parent 37ac91e commit c9521e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -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)
)}`,
Expand All @@ -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 ----------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions playground/css-sourcemap/__tests__/css-sourcemap.spec.ts
Expand Up @@ -90,6 +90,18 @@ describe.runIf(isServe)('serve', () => {
`)
})

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 ')
const map = extractSourcemap(css)
Expand Down

0 comments on commit c9521e7

Please sign in to comment.