Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,12 @@ const scssProcessor = (
? JSON.parse(result.map.toString())
: undefined

if (map) {
map.sources = map.sources.map((url) =>
url.startsWith('file://') ? normalizePath(fileURLToPath(url)) : url,
)
}

return {
code: result.css.toString(),
map,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../css-sourcemap.spec'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../css-sourcemap.spec'
15 changes: 15 additions & 0 deletions playground/css-sourcemap/vite.config-sass-modern-compiler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig, mergeConfig } from 'vite'
import baseConfig from './vite.config.js'

export default mergeConfig(
baseConfig,
defineConfig({
css: {
preprocessorOptions: {
sass: {
api: 'modern-compiler',
},
},
},
}),
)
15 changes: 15 additions & 0 deletions playground/css-sourcemap/vite.config-sass-modern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig, mergeConfig } from 'vite'
import baseConfig from './vite.config.js'

export default mergeConfig(
baseConfig,
defineConfig({
css: {
preprocessorOptions: {
sass: {
api: 'modern',
},
},
},
}),
)
22 changes: 12 additions & 10 deletions playground/vitestGlobalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ export async function setup({ provide }: GlobalSetupContext): Promise<void> {
}
})
// also setup dedicated copy for "variant" tests
await fs.cp(
path.resolve(tempDir, 'css'),
path.resolve(tempDir, 'css__sass-modern'),
{ recursive: true },
)
await fs.cp(
path.resolve(tempDir, 'css'),
path.resolve(tempDir, 'css__sass-modern-compiler'),
{ recursive: true },
)
for (const [original, variants] of [
['css', ['sass-modern', 'sass-modern-compiler']],
['css-sourcemap', ['sass-modern', 'sass-modern-compiler']],
] as const) {
for (const variant of variants) {
await fs.cp(
path.resolve(tempDir, original),
path.resolve(tempDir, `${original}__${variant}`),
{ recursive: true },
)
}
}
}

export async function teardown(): Promise<void> {
Expand Down