Skip to content

Commit adbaa94

Browse files
authored
feat(css): css.devSourcemap option (#7471)
1 parent 0c9b9ec commit adbaa94

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

packages/plugin-vue/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export interface ResolvedOptions extends Options {
6363
compiler: typeof _compiler
6464
root: string
6565
sourceMap: boolean
66+
cssDevSourcemap: boolean
6667
devServer?: ViteDevServer
6768
devToolsEnabled?: boolean
6869
}
@@ -99,6 +100,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
99100
reactivityTransform,
100101
root: process.cwd(),
101102
sourceMap: true,
103+
cssDevSourcemap: false,
102104
devToolsEnabled: process.env.NODE_ENV !== 'production'
103105
}
104106

@@ -137,6 +139,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
137139
...options,
138140
root: config.root,
139141
sourceMap: config.command === 'build' ? !!config.build.sourcemap : true,
142+
cssDevSourcemap: config.css?.devSourcemap ?? false,
140143
isProduction: config.isProduction,
141144
devToolsEnabled:
142145
!!config.define!.__VUE_PROD_DEVTOOLS__ || !config.isProduction

packages/plugin-vue/src/style.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ export async function transformStyle(
2323
isProd: options.isProduction,
2424
source: code,
2525
scoped: block.scoped,
26-
postcssOptions: {
27-
map: {
28-
from: filename,
29-
inline: false,
30-
annotation: false
31-
}
32-
}
26+
...(options.cssDevSourcemap
27+
? {
28+
postcssOptions: {
29+
map: {
30+
from: filename,
31+
inline: false,
32+
annotation: false
33+
}
34+
}
35+
}
36+
: {})
3337
})
3438

3539
if (result.errors.length) {

0 commit comments

Comments
 (0)