Skip to content

Commit

Permalink
feat(css): css.devSourcemap option (#7471)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Mar 26, 2022
1 parent 0c9b9ec commit adbaa94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface ResolvedOptions extends Options {
compiler: typeof _compiler
root: string
sourceMap: boolean
cssDevSourcemap: boolean
devServer?: ViteDevServer
devToolsEnabled?: boolean
}
Expand Down Expand Up @@ -99,6 +100,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
reactivityTransform,
root: process.cwd(),
sourceMap: true,
cssDevSourcemap: false,
devToolsEnabled: process.env.NODE_ENV !== 'production'
}

Expand Down Expand Up @@ -137,6 +139,7 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin {
...options,
root: config.root,
sourceMap: config.command === 'build' ? !!config.build.sourcemap : true,
cssDevSourcemap: config.css?.devSourcemap ?? false,
isProduction: config.isProduction,
devToolsEnabled:
!!config.define!.__VUE_PROD_DEVTOOLS__ || !config.isProduction
Expand Down
18 changes: 11 additions & 7 deletions packages/plugin-vue/src/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ export async function transformStyle(
isProd: options.isProduction,
source: code,
scoped: block.scoped,
postcssOptions: {
map: {
from: filename,
inline: false,
annotation: false
}
}
...(options.cssDevSourcemap
? {
postcssOptions: {
map: {
from: filename,
inline: false,
annotation: false
}
}
}
: {})
})

if (result.errors.length) {
Expand Down

0 comments on commit adbaa94

Please sign in to comment.