Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

please support vite 'css.devSourcemap' config #199

Open
cnzgray opened this issue Jun 16, 2022 · 0 comments
Open

please support vite 'css.devSourcemap' config #199

cnzgray opened this issue Jun 16, 2022 · 0 comments

Comments

@cnzgray
Copy link

cnzgray commented Jun 16, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant