Skip to content

Commit

Permalink
fix(css): remove pure css chunk sourcemap (#14290)
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day authored and bluwy committed Oct 3, 2023
1 parent d4bc0fb commit cd7e033
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -789,6 +789,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
pureCssChunkNames.forEach((fileName) => {
removedPureCssFiles.set(fileName, bundle[fileName] as RenderedChunk)
delete bundle[fileName]
delete bundle[`${fileName}.map`]
})
}

Expand Down
@@ -0,0 +1,8 @@
import { describe, expect, test } from 'vitest'
import { findAssetFile, isBuild } from '~utils'

describe.runIf(isBuild)('css lib entry', () => {
test('remove useless js sourcemap', async () => {
expect(findAssetFile('linked.js.map', 'lib-entry', './')).toBe('')
})
})
1 change: 1 addition & 0 deletions playground/css-sourcemap/index.js
@@ -0,0 +1 @@
export default 'hello'
13 changes: 13 additions & 0 deletions playground/css-sourcemap/vite.config-lib-entry.js
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'

export default defineConfig({
build: {
cssCodeSplit: true,
sourcemap: true,
outDir: 'dist/lib-entry',
lib: {
entry: ['./index.js', './linked.css'],
formats: ['es'],
},
},
})

0 comments on commit cd7e033

Please sign in to comment.