source maps are incorrect when compiling from SCSS
See original GitHub issueI have this Gulp code which compiles three SCSS files (first.scss, last.scss, and app.scss). All plugins are gulp-sourcemaps compatible:
return gulp.src(cssFiles)
.pipe(plugins.if(addSourceMaps, plugins.sourcemaps.init({loadMaps: true})))
.pipe(plugins.sass())
.pipe(plugins.autoprefixer())
// I have verified this code is not the issue--if commented out the problem remains.
.pipe(plugins.if(!!config.cssFile,plugins.order(
[
config.sourceFolder + '**/first.css',
'!' + config.sourceFolder + '**/*',
'!' + config.sourceFolder + '**/last.css'
],
{base: '.'}
)))
.pipe(plugins.if(!!config.cssFile, plugins.concat(config.cssFile)))
.pipe(plugins.if(addSourceMaps, plugins.sourcemaps.write('.', {sourceRoot: '../src'})))
...
When autoprefixer is commented out, the source maps are produced properly:
{"version":3,"sources":["sass/first.scss","sass/app.scss","sass/last.scss"],"names":[],"mappings":"AAAA;ACAA;ACAA","file":"all.css","sourcesContent":["// All CSS files are combined into one big file called \"all.css\". This file is\n// guaranteed to be the first file added (the contents of this file will be at\n// the beginning of \"all.css\").\n\n","// app.scss\n\n","// All CSS files are combined into one big file called \"all.css\". This file is\n// guaranteed to be the last file added (the contents of this file will be at\n// the end of \"all.css\").\n\n"],"sourceRoot":"../src"}
When autoprefixer is enabled, the source maps are incorrect and point to nonexistent CSS files:
{"version":3,"sources":["sass/app.css","sass/first.css","sass/last.css"],"names":[],"mappings":"AAAA;ACAA;ACAA","file":"all.css","sourceRoot":"../src","sourcesContent":[]}
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
source maps are incorrect when compiling from SCSS #55
I have this Gulp code which compiles three SCSS files (first.scss, last.scss, and app.scss). All plugins are gulp-sourcemaps compatible: return ...
Read more >SASS Source Map pointing to the wrong SASS file
Try using gulp-sass and gulp-sourcemaps package with below gulpfile.js to render the sass file with source-map var gulp = require('gulp'); ...
Read more >LegacyStringOptions | JS API - Sass
If this option is a string, it's the path that the source map is expected to be written to, which is used to...
Read more >sass-loader - webpack - JS.ORG
Loads a Sass/SCSS file and compiles it to CSS. ... ℹ In some rare cases node-sass can output invalid source maps (it is...
Read more >Should I Use Source Maps in Production? | CSS-Tricks
It's a valid question. A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok. Just out of curiosity, is this plugin no longer supported? Or is it unfeasible to fix this for technical reasons?
@alvint yeap, no problem 😃