PostCSS generates inline sourcemap by default


#1

The documentation states:

noMap [bool]
Default is true . Disable the default inline sourcemaps

But the inline sourcemap is still generated. If I set “noMap” to true, the inline sourcemap is still generated. However, if I set “no-map” to true then the inline sourcemap is not generated (as desired).

This generates an inline sourcemap (FAIL):

  {{- $optionsToCSS := (dict "outputStyle" "compressed") -}}
  {{- $optionsPostCSS := (dict "use" "autoprefixer") -}}
  {{- $css := resources.Get "css/main.scss" | resources.ToCSS $optionsToCSS | resources.PostCSS $optionsPostCSS -}}

This also generates an inline sourcemap (FAIL):

  {{- $optionsToCSS := (dict "outputStyle" "compressed") -}}
  {{- $optionsPostCSS := (dict "noMap" true "use" "autoprefixer") -}}
  {{- $css := resources.Get "css/main.scss" | resources.ToCSS $optionsToCSS | resources.PostCSS $optionsPostCSS -}}

This does not generate an inline source map (PASS):

  {{- $optionsToCSS := (dict "outputStyle" "compressed") -}}
  {{- $optionsPostCSS := (dict "no-map" true "use" "autoprefixer") -}}
  {{- $css := resources.Get "css/main.scss" | resources.ToCSS $optionsToCSS | resources.PostCSS $optionsPostCSS -}}

Environment:

  • Ubuntu 18.04.2 LTS
  • Hugo Static Site Generator v0.54.0/extended linux/amd64 BuildDate: 2019-02-01T13:31:26Z (installed from snap)

Per the documentation, because I installed the Hugo snap package, I installed postcss-cli and autoprefixer in the Hugo site directory with:

$ npm install postcss-cli
$ npm install autoprefixer

Is the documentation incorrect? Is this a bug? Or am I doing something wrong?


#2

I have this in my partial and it works. It’s conditional and enables SourceMap in ServerMode only.

{{ $cssOpts := cond ($inServerMode) (dict "targetPath" $cssTarget "enableSourceMap" true "includePaths" $sassIncludes) (dict "targetPath" $cssTarget "includePaths" $sassIncludes "outputStyle" "compressed") }}

Hope this helps


#3

Thanks. It looks like your $cssOpts is for ToCSS. My problem with noMap is related to PostCSS.


#4

I see. Can’t help though.


#5

I’m not sure if this is helpful, but there’s a subtle distinction in the commands for when you are or are not using a config file, where the noMap command “seems” to be for when you’re using a config file.

You can see it more clearly in the CLI docs https://github.com/postcss/postcss-cli