question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with gulp-sass ? Or gulp-autoprefixer ? Or gulp-sourcemaps ?

See original GitHub issue

Hi,

There is a lot of issue about mixing gulp-sass and/or gulp-autoprefixer with gulp-sourcemaps.

For example : https://github.com/dlmanning/gulp-sass/issues/106, https://github.com/sindresorhus/gulp-autoprefixer/issues/8

I just spend 2 hours debugging to find out where the problem come from, and still no success.

But I finally noticed something (but still don’t know where the problem come from).

In source-map-generator.js @ Line 359, I watched the key value.

In this configuration:

gulp.task('css', function () {
    gulp.src('./assets/sass/style.scss')
        .pipe(sourcemaps.init())
        .pipe(sass())
        //.pipe(sourcemaps.write({includeContent: false}))
        //.pipe(sourcemaps.init({loadMaps: true}))
        .pipe(autoprefixer())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./public/css'))
});

The value of the key is $style.css, and it does not work

But in this configuration:

gulp.task('css', function () {
    gulp.src('./assets/sass/style.scss')
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(sourcemaps.write({includeContent: false}))
        .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(autoprefixer())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./public/css'))
});

The value of the key is $style.scss, and it works

Because with the two configurations, _sourcemapContents in source-map-generator.js#360 has always a $style.scss key.

Hope this helps to resolve this issue, and to find if the problem come from sourcemap, sass or autoprefixer (or something else)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
HectorLScommented, May 19, 2016

Hi, i was reading that the new version fixed the problem, but i installed today
“gulp”: “^3.9.1”, “gulp-autoprefixer”: “^3.1.0”, “gulp-sass”: “^2.3.1”, “gulp-sourcemaps”: “^1.6.0”,

And doesn’t work if i do:

gulp.task('sass', () => {
  log('Compiling SCSS files...');
  return gulp
    .src('./src/app/**.*scss')
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({ browser: ['last 2 version', '> 5%'] }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./.temp/'));
});

But if i added the @ByScripts two MAGIC LINES works

// THIS WORKS
gulp.task('sass', () => {
  log('Compiling SCSS files...');
  return gulp
    .src('./src/app/**.*scss')
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(sourcemaps.write({includeContent: false}))
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(autoprefixer({ browser: ['last 2 version', '> 5%'] }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./.temp/'));
});

When this would be fixed to don’t need that two lines… is like zero readable… :S

3reactions
ByScriptscommented, Nov 9, 2014

Don’t know if it’s related. In my sample I don’t import any other scss files, and I don’t get any error.

Here is a sample project: https://github.com/ByScripts/gulp-sample

Just running npm install then gulp should do the work.

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Sourcemaps not generating properly with gulp, SASS ...
The problem I'm having is the SASS compiler is properly generating the sourcemaps and adding the sourcemap comment, but then autoprefixer removes the...
Read more >
How to use the gulp-sass function in gulp-sass | Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Using Gulp, Browser-sync and Source maps | by Nirazan Basnet
Last few weeks i have been using Gulp and Recently I changed my workflow, using some of the best tools available: Browser-Sync and...
Read more >
Setting up gulp 4 for automatic Sass compilation and CSS ...
Step 1: Sass/Scss compilation · Step 2: Automating tasks · Step 3: Make it DRYer · Step 4: Let's add sourcemaps, autoprefixer and...
Read more >
Using Gulp with Dart Sass - Zell Liew
Sourcemaps, PostCSS, and extra plugins. You can add PostCSS plugins like autoprefixer by requiring them in the gulpfile too. Here's how to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found