vite-plugin-vue2
vite-plugin-vue2 copied to clipboard
please support vite 'css.devSourcemap' config
Looking at the source code of style in @vite/plugin-vue, you can find that there is a piece of code as follows(https://github.com/vitejs/vite/blob/HEAD/packages/plugin-vue/src/style.ts#L26):
const block = descriptor.styles[index]
// vite already handles pre-processors and CSS module so this is only
// applying SFC-specific transforms like scoped mode and CSS vars rewrite (v-bind(var))
const result = await options.compiler.compileStyleAsync({
...options.style,
filename: descriptor.filename,
id: `data-v-${descriptor.id}`,
isProd: options.isProduction,
source: code,
scoped: block.scoped,
...(options.cssDevSourcemap
? {
postcssOptions: {
map: {
from: filename,
inline: false,
annotation: false
}
}
}
: {})
})
There is an option to turn off the sourcemap output of css. And that option comes from the configResolved hook in index.ts.(see https://github.com/vitejs/vite/blob/HEAD/packages/plugin-vue/src/index.ts#L132)
By tracking the compilation process of vite, it is not difficult to find that the preprocessing of vite's style does not output a sourcemap under the action of the css.devSourcemap configuration, but the current plugin directly provides a sourcemap, which leads to inconsistency in behavior.