diff --git a/packages/playground/vue-sourcemap/Css.vue b/packages/playground/vue-sourcemap/Css.vue index 19668de8d33965..4f677c7b84dfbd 100644 --- a/packages/playground/vue-sourcemap/Css.vue +++ b/packages/playground/vue-sourcemap/Css.vue @@ -2,6 +2,7 @@
<css>
<css> module
<css> scoped
+<css> scoped with nested
+ + diff --git a/packages/playground/vue-sourcemap/__tests__/serve.spec.ts b/packages/playground/vue-sourcemap/__tests__/serve.spec.ts index 08b4c04face111..7dfa271deea322 100644 --- a/packages/playground/vue-sourcemap/__tests__/serve.spec.ts +++ b/packages/playground/vue-sourcemap/__tests__/serve.spec.ts @@ -80,7 +80,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAOA;EACE,UAAU;AACZ", + "mappings": ";AAQA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -89,6 +89,7 @@ if (!isBuild) {<css>
<css> module
<css> scoped
+<css> scoped with nested
+ + ", ], "version": 3, @@ -120,7 +131,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAaA;EACE,UAAU;AACZ", + "mappings": ";AAcA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -129,6 +140,7 @@ if (!isBuild) {<css>
<css> module
<css> scoped
+<css> scoped with nested
+ + ", ], "version": 3, @@ -160,7 +182,7 @@ if (!isBuild) { const map = extractSourcemap(css) expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(` Object { - "mappings": ";AAmBA;EACE,UAAU;AACZ", + "mappings": ";AAoBA;EACE,UAAU;AACZ", "sources": Array [ "/root/Css.vue", ], @@ -169,6 +191,7 @@ if (!isBuild) {<css>
<css> module
<css> scoped
+<css> scoped with nested
+ + ", ], "version": 3, diff --git a/packages/playground/vue-sourcemap/package.json b/packages/playground/vue-sourcemap/package.json index 286940b01efa58..25bd2b725b7e65 100644 --- a/packages/playground/vue-sourcemap/package.json +++ b/packages/playground/vue-sourcemap/package.json @@ -11,7 +11,8 @@ "devDependencies": { "@vitejs/plugin-vue": "workspace:*", "less": "^4.1.2", - "sass": "^1.43.4" + "sass": "^1.43.4", + "postcss-nested": "^5.0.6" }, "dependencies": { "vue": "^3.2.31" diff --git a/packages/playground/vue-sourcemap/postcss.config.js b/packages/playground/vue-sourcemap/postcss.config.js new file mode 100644 index 00000000000000..9ea26b495d91b5 --- /dev/null +++ b/packages/playground/vue-sourcemap/postcss.config.js @@ -0,0 +1,3 @@ +module.exports = { + plugins: [require('postcss-nested')] +} diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index cff7eaaf3e4c52..b3ea3338cecc04 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -877,32 +877,23 @@ export function formatPostcssSourceMap( ): ExistingRawSourceMap { const inputFileDir = path.dirname(file) - const sources: string[] = [] - const sourcesContent: string[] = [] - for (const [i, source] of rawMap.sources.entries()) { - // remove