rollup-plugin-postcss icon indicating copy to clipboard operation
rollup-plugin-postcss copied to clipboard

Sourcemap file points to the compiled scss when its setting is `true`

Open norixx opened this issue 2 years ago • 0 comments

I am using the plugin to deal with multiple .scss files(partials)

The problem is that depending on whether the sourceMap setting is 'inline' or true, the result of the output file will be different.

My folder structure is simple like this:

  • 📁src
    • 📁 partials
      • _part1.scss
      • _part2.scss
      • _index.scss (File to forwards part1 and part2)
    • style.scss

If the setting is 'inline', it's no problem that the inlined sourcemap points to the right partial file. But if I set it to true, the sourcemap file just points to style.scss, which for some reason appears to be compiled.

style.scss(just forwards partial files nothing else)

@forward "./scss/";

rollup.config.js

plugins: [
  postcss({
    extract: true,
    sourceMap: true,
    minimize: {
      preset: [
        'default',
        { discardComments: false }
      ]
    },
    plugins: [
      autoprefixer(),
    ]
  })
]

Output

{"version":3,"sources":["style.scss"],"names":[],"mappings":"....","file":"bundle.css","sourcesContent":[".local {\n  background-color: rgb(255, 230, 32);\n}\n\n::selection {\n  color: white;\n  background: blue;\n}\n\nh1 {\n  color: #333;\n}\n\n.test {\n  background-color: rgb(255, 230, 32);\n  font-size: calc(14px + 2vw);\n  color: green;\n  border-bottom: 2px solid greenyellow;\n}"]}

I also do not need sourcesContent which makes my compiled css almost twice as big.

I'm not a Postcss expert, so I may be misguided.

norixx avatar Jun 13 '23 14:06 norixx