Node-sass: CLI Options -x, --omit-source-map-url Do Not Work. Source Map URL Comment Outputs Regardless.

Created on 20 Jul 2018  路  7Comments  路  Source: sass/node-sass

I cannot get node-sass to omit the source map URL comment from output. I am using the CLI like so:

node-sass --output-style compressed -o static/ -x  sass/
  • NPM version: 6.2.0
  • Node version: 10.7.0
  • Node Process:
{ http_parser: '2.8.0',
  node: '10.7.0',
  v8: '6.7.288.49-node.15',
  uv: '1.22.0',
  zlib: '1.2.11',
  ares: '1.14.0',
  modules: '64',
  nghttp2: '1.32.0',
  napi: '3',
  openssl: '1.1.0h',
  icu: '62.1',
  unicode: '11.0',
  cldr: '33.1',
  tz: '2018e' }
  • Node Platform: darwin
  • Node architecture: x64
  • node-sass version:
node-sass   4.9.2   (Wrapper)   [JavaScript]
libsass     3.5.4   (Sass Compiler) [C/C++]

Most helpful comment

@Jarvl, I don't know if this helps, but what I discovered after pulling my hair out over this option not working is that it was actually postcss-cli that was generating the source map url, and not node-sass at all. My npm scripts, in part:

"build-prod:css": "run-s lint-scss-prod scss-prod autoprefixer-prod",
"lint-scss-prod": "stylelint src/prod/assets/scss/*.scss --syntax scss || true",
"scss-prod": "node-sass --include-path node_modules/bourbon/core --output-style compressed -o dist/prod/assets/css src/prod/assets/scss",
"autoprefixer-prod": "postcss -u --no-map autoprefixer -r dist/prod/assets/css/*.css",    

Adding the "--no-map" option to postcss did the trick to remove the code I'd been seeing.

All 7 comments

Hopefully this is just user error on my part. It is getting a bit late for me.

I believe you also need to the --source-map in order to start capturing source maps.

Thanks for the timely input but I do not follow. I want my output to be clean of this comment:

 /*# sourceMappingURL=data:application/json;base64,

My mistake. That's weird. I'll have to look into it later.

User error, sorry for the hassle. Thank you very much for your time and effort.

@MateusAmin What did you end up doing to resolve this?

@Jarvl, I don't know if this helps, but what I discovered after pulling my hair out over this option not working is that it was actually postcss-cli that was generating the source map url, and not node-sass at all. My npm scripts, in part:

"build-prod:css": "run-s lint-scss-prod scss-prod autoprefixer-prod",
"lint-scss-prod": "stylelint src/prod/assets/scss/*.scss --syntax scss || true",
"scss-prod": "node-sass --include-path node_modules/bourbon/core --output-style compressed -o dist/prod/assets/css src/prod/assets/scss",
"autoprefixer-prod": "postcss -u --no-map autoprefixer -r dist/prod/assets/css/*.css",    

Adding the "--no-map" option to postcss did the trick to remove the code I'd been seeing.

Was this page helpful?
0 / 5 - 0 ratings