Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting incorrect path with sourcemaps, am I doing something wrong? #498

Closed
MattHoneycutt opened this issue May 19, 2016 · 15 comments
Closed

Comments

@MattHoneycutt
Copy link

I'm very new to this package, so it's quite possible I'm doing something wrong or that it isn't a gulp-sass issue. Any help, or a nudge in the right direction, is greatly appreciated. :)

That said:

I'm using gulp-sass with bootstrap-sass. I'm starting with a simple SCSS file, vendor.scss:

@import "../../../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss";
@import "custom.scss";

My custom.scss:

body {
    background-color: pink;
}

And my gulp task:

gulp.task('css:vendor', function() {
    return gulp.src('./client/features/shared/vendor.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({ outputStyle: 'compressed', sourceComments: 'map' }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./dist'));
});

Everything builds, the resulting CSS is what I would expect, but the sourcemap is off for the style from my custom.scss. It seems to be "stuck" on the last file that was processed from bootstrap's package:

image

Any tips or suggestions?

@MattHoneycutt
Copy link
Author

I've tried a few different configurations of things, but I'm still getting the same behavior. Any advice?

@zephster
Copy link

zephster commented Jun 6, 2016

Have you tried using outputStyle: 'compact' instead of compressed? I have the same issue when I use compressed, but changing it to compact fixes it. I haven't found a proper solution for this issue, because I would prefer to use compressed.

@anthonyhastings
Copy link

Yep my fix is the same, had to use compact. No idea why this works.

@Sash-OK
Copy link

Sash-OK commented Jul 22, 2016

the problem has not been solved? When i use autoprefixer ,outputStyle: compact does not help, Chrome DevTools shows that all children are on a parent line in the file SCSS

@MattHoneycutt
Copy link
Author

outputStyle: compact doesn't work for me, either. :(

@luketeaford
Copy link

@Sash-OK If you are running autoprefixer on your outputted Scss, I would expect it to break the associations between rules and the source maps.

@MattHoneycutt
Copy link
Author

I'm seeing it break even without autoprefixer, using outputStyle: compact. That doesn't mean autoprefixer isn't breaking things, too, but it isn't the culprit in my case.

@luketeaford
Copy link

@MattHoneycutt I think you should change
.pipe(sass({ outputStyle: 'compressed', sourceComments: 'map' }))

to

.pipe(sass({ outputStyle: 'compressed'})) or .pipe(sass())

I haven't payed close attention to Gulp Sass, but now I notice that sourcemaps are a different plugin rather than an option of Gulp Sass. (If this doesn't work, perhaps calling sourcemaps(write()) will fix it?)

@Dellkan
Copy link

Dellkan commented Oct 4, 2016

Also having this issue. Using {outputStyle: 'compact'} instead of {outputStyle: 'compressed'} gives me correct sourceMaps.

@JoshMoreno
Copy link

Still waiting for a fix.

@Dellkan , @MattHoneycutt - The first problem is bootstrap _breadcrumbs.scss. I opened an issue over there - twbs/bootstrap-sass#1105

Their variable interpolation value in _breadcrumbs.scss causes libsass to:

  1. not compile correctly (don't worry it's just messes up that one line)
  2. mess up sourcemaps when the output style is set to compressed

After you fix that issue, it appears that there is something gulp-sass has to fix because node-sass compiles everything fine (after fixing bootstrap issue) when running --output-style compressed --source-map true. I'm trying to come up with a temporary solution, that doesn't involve using a different tool to minify so we can keep the speed gains from libsass, until the issues are resolved.

@JoshMoreno
Copy link

@Dellkan @MattHoneycutt I think I spoke too soon. I don't think it's a problem with gulp-sass anymore. I still had postcss running autoprefixer in the stream. When I commented that out and just ran gulp-sass with sourcemaps and outputStyle: 'compressed' it's working fine.

So it seems like the problem is postcss or autoprefixer. Will update as I find out more. The bootstrap breadcrumbs issue still holds true though as it messes up libsass itself.

@chris-sparks
Copy link

chris-sparks commented Jun 6, 2017

I can confirm that simply commenting out the .pipe(autoprefixer()) solved my issues with Sourcemaps incorrectly reporting files/line numbers suggesting autoprefixer is the culprit here. I'm not using BS in this instance.

@xzyfer
Copy link
Collaborator

xzyfer commented Aug 31, 2017

This is either an issue with libsass (used by gulp-sass), or another gulp plugin interfering.

Comment out all other gulp-plugins. If the issue persists open an issue with libsass.

@xzyfer xzyfer closed this as completed Aug 31, 2017
@andywarren
Copy link

Just wanted to add to this as well. I also have the issue with sourcemaps not matching up correctly, and can also confirm it is strictly happening when the outputStyle: 'compressed' option is passed in. When changing it to outputStyle: 'compact' the sourcemaps again match up correctly. I'd really like to be able to have the stylesheet completely minified though.

@JoshMoreno
Copy link

For anyone digging around, the issue isn't with gulp-sass.

It's a known issue. Libsass (maybe node sass) seems to still have a bug - sass/node-sass#957

Also, PostCSS isn't fully compatible with sass sourcemaps and the issue has been closed as won't fix (though he tried 👍) - postcss/postcss#926

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

No branches or pull requests

10 participants