Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(css): remove css-post plugin sourcemap #9914

Merged
merged 3 commits into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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