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

How to use in combination with gulp-sass #8

Closed
lmartins opened this issue Sep 29, 2014 · 53 comments
Closed

How to use in combination with gulp-sass #8

lmartins opened this issue Sep 29, 2014 · 53 comments

Comments

@lmartins
Copy link

Hi,

Im trying to use gulp-autoprefixer in combination with gulp-sass and gulp-sourcemaps.
My gulpfile task looks like this:

gulp.task('sass', function () {
  gulp.src( config.SASS.src )
    .pipe( plugins.sourcemaps.init() )
    .pipe( plugins.sass() )
    .pipe( plugins.autoprefixer (
      "last 1 versions", "> 10%", "ie 9"
      ))
    .pipe( plugins.sourcemaps.write('./') )
    .pipe( gulp.dest( config.SASS.build ) )
    .pipe( browserSync.reload({ stream: true }) );
});

The plugins. prefix is related to gulp-load-plugins

Without gulp-sass the task runs fine, but with it it throws the following error:

[08:26:51] Finished 'sass' after 3.32 ms
gulp-sourcemap-write: source file not found:/Users/luismartins/Sites/00_LAB/wp-multisite/wp-content/themes/wip053/src/sass/main.css

Should I be running autoprefixer as a separate task after CSS compilation?

Thanks.

@davidtheclark
Copy link

I wonder if this is connected to dlmanning/gulp-sass#92. I was getting the same kind of error message from gulp-sass.

@klingberg
Copy link

It is the same issue when used in combination with plus3network/gulp-less.

@valdelama
Copy link

+1
I have the same issue

@battaglr
Copy link

battaglr commented Oct 3, 2014

This conversation shouldn't be here and I should close it... but since sourcemaps are being the source —no pun intended— of many headaches, I think this could remain open for a while.

What do you think @sindresorhus?

@valdelama
Copy link

@battaglr It seems that autoprefixer is stripping out the sourcemaps so I figured this was the right place. Where should the bug be posted?

@battaglr
Copy link

battaglr commented Oct 3, 2014

@valdelama: this one is not a bug of gulp-autoprefixer —it's not even generating the problem in this case—, so you should ask for help on Stack Overflow or the like. But it's true that sourcemaps aren't playing nice across different gulp plugins —see #1 and #2—, that's why I said that this could remain open until things get better.

@subblue
Copy link

subblue commented Oct 9, 2014

I've had all the various sourcemap problems reported when trying to use gulp-sass, gulp-sourcemap and gulp-autoprefixer. After fiddling around for ages this is the final task template that works for me:

gulp       = require('gulp');
sass       = require('gulp-sass'); // 1.0.0
sourcemaps = require('gulp-sourcemaps');  // v1.2.2
autoprefix = require('gulp-autoprefixer');  // v1.0.1

gulp.task('styles', function() {
  return gulp.src('src/scripts/app/app.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({errLogToConsole: true}))
    .pipe(sourcemaps.write({includeContent: false, sourceRoot: '.'}))

    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(autoprefix({browsers: ['last 1 version', 'iOS 6'], cascade: false}))
    .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '../scripts/app'}))

    .pipe(gulp.dest('www/css'));
});

The things that made it work for me are wrapping sourcemaps calls around the sass and autoprefixer separately, passing the maps from the first into the second (with loadMaps) and the includeContent and sourceRoot options passed into the sourcemaps.write() methods.

Because the source maps don't include the original content I'm allowing my dev server access to the original .scss files too, so that from the Chrome dev console I can click on the scss file name and view the original source directly. The dev console actually feels a little snappier this way too with large stylesheets.

The line numbering to the original file is slightly out due to autoprefixer adding the additional prefixed lines, but the important thing is that very quickly and with low friction I can find the style settings in the original .scss file.

@wagerfield
Copy link

Has there been any progress on this? I am experiencing exactly the same issue.

var gulp = require('gulp'),
    sass = require('gulp-sass'),
    rename = require('gulp-rename'),
    sourcemaps = require('gulp-sourcemaps'),
    autoprefixer = require('gulp-autoprefixer');

gulp.task('styles', function() {
    return gulp.src('app/index.scss')

        // Initialise sourcemaps prior to compiling SASS.
        .pipe(sourcemaps.init())

        // Compile SASS.
        .pipe(sass({outputStyle: 'compressed'}))

        // Rename index.scss file to styles.css.
        .pipe(rename({basename: 'styles'}))

        // Write sourcemap inline.
        .pipe(sourcemaps.write())

        // Reinitialise sourcemaps, loading inline sourcemap.
        .pipe(sourcemaps.init({loadMaps: true}))

        // Run compiled CSS through autoprefixer.
        .pipe(autoprefixer({browsers: ['last 2 versions']}))

        // Write sourcemap to a separate file.
        .pipe(sourcemaps.write('./'))

        // Write CSS file to desitination path.
        .pipe(gulp.dest('static/css/'));
});

It's also worth noting that I have a components directory alongside app and static that contains various components with their own .scss files. These files are being imported into app/index.scss:

app/index.scss

// COMPONENT IMPORTS
@import '../components/component-one/index.scss';
@import '../components/component-two/index.scss';

// APP IMPORTS
@import 'layout.scss';
@import 'tablet.scss';
@import 'mobile.scss';

Without the autoprefixer step, this task works without errors and produces external sourcemaps that work correctly. As soon as I introduce the autoprefixer step, I get the following error in the console:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: "/components/component-one/index.scss" is not in the SourceMap.
    at SourceMapConsumer_sourceContentFor [as sourceContentFor] ([...]/node_modules/gulp-autoprefixer/node_modules/vinyl-sourcemaps-apply/node_modules/source-map/lib/source-map/source-map-consumer.js:380:13)
    at SourceMapGenerator.<anonymous> ([...]/node_modules/gulp-autoprefixer/node_modules/vinyl-sourcemaps-apply/node_modules/source-map/lib/source-map/source-map-generator.js:229:42)
    at Array.forEach (native)
    at SourceMapGenerator_applySourceMap [as applySourceMap] ([...]/node_modules/gulp-autoprefixer/node_modules/vinyl-sourcemaps-apply/node_modules/source-map/lib/source-map/source-map-generator.js:228:34)
    at applySourceMap ([...]/node_modules/gulp-autoprefixer/node_modules/vinyl-sourcemaps-apply/index.js:23:15)
    at DestroyableTransform._transform ([...]/node_modules/gulp-autoprefixer/index.js:35:5)
    at DestroyableTransform.Transform._read ([...]/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write ([...]/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite ([...]/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer ([...]/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)

If I remove the imports to the component index.scss files, I then get an error from gulp-sourcemaps:

gulp-sourcemap-write: source file not found: `[...]/app/styles.css`

I assumed this was coming from the rename step I was doing, so I updated the task to output styles.css twice in the task like so:

gulp.task('styles', function() {
    return gulp.src('app/index.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({outputStyle: 'compressed'}))
        .pipe(rename({basename: 'styles'}))
        .pipe(sourcemaps.write())

        // Outputting styles.css remedies this error from gulp-sourcemaps...but I feel like it's a hack?
        .pipe(gulp.dest('static/css/'));

        .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(autoprefixer({browsers: ['last 2 versions']}))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('static/css/'));
});

@sindresorhus as an author on both sourcemaps and autoprefixer, I was hoping you could take a look at this?

Many thanks for everyone's work on these plugins, they are truly awesome!

@jednano
Copy link

jednano commented Oct 25, 2014

This appears to work for me, using gulp-sass, gulp-sourcemaps, gulp-autoprefixer, gulp-minify-css and gulp-csscomb:

gulp.task('styles', function() {
  return gulp.src('src/styles/**/*.scss')
    .pipe($.plumber())
    .pipe($.if(!RELEASE, $.sourcemaps.init()))
    .pipe($.sass({
      errLogToConsole: true
    }))
    .pipe($.if(!RELEASE, $.sourcemaps.write({
      includeContent: false,
      sourceRoot: '.'
    })))
    .pipe($.if(!RELEASE, $.sourcemaps.init({loadMaps: true})))
    .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    .pipe($.csscomb())
    .pipe($.if(RELEASE, $.minifyCss()))
    .pipe($.if(!RELEASE, $.sourcemaps.write({
      includeContent: false,
      sourceRoot: '.'
    })))
    .pipe(gulp.dest(DEST + '/css'))
    .pipe($.size({title: 'styles'}));
});

@wagerfield
Copy link

@jedmao I've seen a few implementations using includeContent: false, sourceRoot: '/some/path/' but would much rather have the source mapping packaged up into the .map file since the source code for a lot of the projects I work on cannot easily be hosted on the server for security reasons. Furthermore all bundled scripts and styles are compiled out to a static directory that is partitioned from our source directory.

Does anyone have a solution that does not use includeContent: false?

@jednano
Copy link

jednano commented Oct 27, 2014

I would love to see a similar example.

@dwayne-roberts
Copy link

@sindresorhus is it possible to use use gulp-sass in combination with gulp-autoprefixer and external sourcemaps via gulp-sourcemaps? Or is the above solution with inline sourcemaps the only option now?

@GalCohen
Copy link

GalCohen commented Nov 9, 2014

👍 same problem here

@ahdinosaur
Copy link

i'm also interested in a solution using gulp-sass in combination with gulp-autoprefixer and external sourcemaps via gulp-sourcemaps, cheers for everyone's great work.

EDIT: this mostly works (somehow line numbers are off by a few lines), had to also downgrade gulp-sass to 1.1.0.

  gulp.src(sassSrc)
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass(
      includePaths: sassIncludes
    ))
    .pipe(sourcemaps.write(includeContent: false))
    .pipe(sourcemaps.init(loadMaps: true))
    .pipe(autoprefix(
      browsers: ['> 1%', 'last 2 versions']
    ))
    .pipe(sourcemaps.write('../maps'))
    .pipe(gulp.dest('build/styles'))

@dtothefp
Copy link

+1 this is sad that this is still such a wide-spread issue for something seeming so trivial. Also, disheartening that it probably forces many users to use ruby-sass. I couldn't get any of the above examples to work for external source maps. Only way I could do it which was to run two sync tasks and inject the sourcemap comment that autoprefixer strips out:

gulp.task('sass', function () {
  var stream = gulp.src(config.src)
    .pipe(sourcemaps.init())
    .pipe(sass({
      errLogToConsole: true
    }))
    .pipe(sourcemaps.write('./', {
      sourceRoot: '../../src'
    }))
    .on('error', handleErrors)
    .pipe(gulp.dest(config.dest));

  return stream;
});

gulp.task('autoprefix', ['sass'], function () {
  return gulp.src(config.dest + '/*.css')
    .pipe(autoprefixer({
        browsers: ['last 2 versions'],
        cascade: true
    }))
    .pipe(insert.append('\n\n/*# sourceMappingURL=app.css.map */'))
    .on('error', handleErrors)
    .pipe(gulp.dest(config.dest));
});

@myqianlan
Copy link

+1

autoprefixer also rewirte the css files, so we can not found sass sourcemap in css files, It's not awesome.Can we found a way to solve this ?

@leepowelldev
Copy link

Same problem. Having to write and load sourcemaps before they pipe through plugin. Some of the sourcemap files are showing in chrome inspector, some point to the generated .css files.

@wesbos
Copy link

wesbos commented Dec 9, 2014

@sindresorhus Having this issue too - any plans to tackle this?

@steveszc
Copy link

Also having this issue.
node-sass, autoprefixer, sourcemaps. Seems you can only get two to work together, but not all three.

@myqianlan
Copy link

I come back once again , is there have any beautiful way to deal with?

@polarathene
Copy link

Inline/external sourcemaps work fine, I've come across blog posts and the like saying the issue is with autoprefixer but have been looking into the issue and discovered libsass isn't outputting proper sourcemaps. If you're using libsass check that the sourcemap it produces is functional, in my experience it links to the scss file but fails to match lines. I found out why and you can see here. The good news is it should be fixed with libsass 3.2 :)

@myqianlan There are lot of options, you can write separate files using two destinations or tasks, or change name with gulp-rename. You can also include the scss->css source in the sourcemap, that can go inside your css, just use .pipe(gulp_sourcemaps.write()), then before using gulp-autoprefixer add .pipe(gulp_sourcemaps.init({loadMaps: true})).

Autoprefixer works, and handles sourcemap properly. Problem is libsass is making invalid sourcemap, all the mappings from the css to scss are at the beginning of the file, autoprefixer is not at fault. Until libsass 3.2 (and node-sass/gulp-sass work with it), you will not get valid sourcemap for your scss files.

@myqianlan
Copy link

@polarathene thanks,I will take a try.

@polarathene
Copy link

@myqianlan There was an update to gulp-sass today, I've talked about it and provided some code sample here both inline and external sourcemaps with embedded or external sources.

Hope it helps the rest of you too :)

@Avcajaraville
Copy link

Still love to get a solution for this.

Weird thing is that it is working fine for one of my files (we have an admin & public css); when I compile something, in one of the views (public), everything works fine; but for the other (admin), google developers tools cant even show the file that create the style (the file that you see on the style tab when inspecting, right to the classes name).

This is getting very weird... If I disable then autoprefixer, everything works fine.

Anybody ?

@1Copenut
Copy link

I was having this same issue today, but got it to work correctly by moving the Autoprefixer .pipe rule below the sourcemaps.write. I've tested that it works in Chrome and Firefox latest, using the "Show Original Sources" checkbox from the Settings menu.

gulp.task('sass', function() {
    gulp.src('app/styles/sass/*.scss')
      .pipe(sourcemaps.init())
          .pipe(sass())
      .pipe(sourcemaps.write())
      .pipe(autoprefixer({browsers: ['last 2 versions']}))
      .pipe(gulp.dest('app/styles/css'));
});

@lmartins
Copy link
Author

Im going to try that, but I suspect that will skew your line numbers in the css inspector because autoprefixer will add lines to the code, changing the location your source map originally haves.

@jacobsvante
Copy link

I'm not having the same luck with @superbiche's solution...

$ gulp styles:

[17:34:24] Using gulpfile ~/apps/myapp/gulpfile.js
[17:34:24] Starting 'clean-styles'...
[17:34:24] Finished 'clean-styles' after 13 ms
[17:34:24] Starting 'styles'...
[17:34:25] Plumber found unhandled error:
 Error in plugin 'gulp-autoprefixer'
Message:
    "/styles/fonts.scss" is not in the SourceMap.
Details:
    fileName: /Users/jacob/apps/myapp/dist/styles/main.css
[17:34:25] Finished 'styles' after 809 ms

$ cat gulptasks/styles.coffee:

autoprefixer = require('gulp-autoprefixer')
sass = require('gulp-sass')
sourcemaps = require('gulp-sourcemaps')
plumber = require('gulp-plumber')
gulpFilter = require('gulp-filter')
config = require('./config')

gulp.task('styles', ['clean-styles'], ->
  # Prevent reading sourcemaps to autoprefix them or make sourcemaps of sourcemaps
  filter = gulpFilter(['*.css', '!*.map'])

  return gulp.src("#{config.STYLE_PATH}/main.scss")
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(sass({ errLogToConsole: true }))
    .pipe(sourcemaps.write('./'))
    .pipe(filter)
    .pipe(autoprefixer({ browsers: ['last 2 versions' ], cascade: true }))
    .pipe(filter.restore())
    .pipe(gulp.dest(config.STYLE_PATH_DIST))
)

$ npm ls --depth 0:

├── gulp@3.8.11
├── gulp-autoprefixer@2.1.0
├── gulp-filter@2.0.2
├── gulp-plumber@1.0.0
├── gulp-sass@1.3.3
├── gulp-sourcemaps@1.5.1

@dmnplb
Copy link

dmnplb commented Apr 16, 2015

Thank you, @superbiche. Your solution worked.
Here's my gulp task (I've replaced gulp-filter with gulp-if):

gulp.src()
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      precision: 10,
      errLogToConsole: true,
      // indentedSyntax: true, → Sass Syntax
      outputStyle: 'nested'
    }))
    .pipe($.sourcemaps.write('.'))
    .pipe($.if(['*.css', '!*.map'], $.autoprefixer()))
    .pipe(gulp.dest());

Packages:

├── gulp@3.8.11
├── gulp-autoprefixer@2.1.0
├── gulp-if@1.2.5
├── gulp-sass@1.3.3
├── gulp-sourcemaps@1.5.2

@1Copenut
Copy link

@jmagnusson Is it possible your Gulpfile is not working because you're running a Ruby-style string interpolation on the return line? You might try this:

return gulp.src(config.STYLE_PATH + '/main.scss')

and see if that resolves the error.

@1Copenut
Copy link

@dmnplb I like your solution to use the $.if statement for Autoprefixer.

@jacobsvante
Copy link

@1Copenut I don't believe so. It's just CoffeeScript which is transformed into that very string you wrote.

@jacobsvante
Copy link

@sindresorhus Why was this closed?

@sindresorhus
Copy link
Owner

It's not an issue with this plugin, but rather gulp-sass (or rather libsass). I've gotten reports that it should be resolved in the unreleased gulp-sass 2.0: https://github.com/dlmanning/gulp-sass/tree/2.x

@jacobsvante
Copy link

@sindresorhus Thanks for the info. Do we have any gulp-sass issues touching this?

@pjlong
Copy link

pjlong commented Apr 21, 2015

@1Copenut 's solution worked for me in Chrome using:

"autoprefixer": "^5.1.1",
"gulp": "^3.8.11",
"gulp-autoprefixer": "^2.1.0",
"gulp-sass": "^1.3.3",
"node-sass": "^2.0.1"

@pyronaur
Copy link

This works for me for now, same versions as @pjlong

    gulp.src("#{Config.sass.source}/app.sass")
        .pipe maps.init()
        .pipe sass {
                       precision: 3,
                       outputStyle: 'nested'
                       indentedSyntax: true
                   }
        .on("error", error_handle)
        .pipe maps.write('.')
        .pipe(g_if(['*.css', '!*.map'], autoprefixer()))
        .pipe gulp.dest(Config.build)

@pyronaur
Copy link

pyronaur commented May 1, 2015

Turns out the gulp.if solution doesn't work at all. It just skips autoprefixer task. Noticed that only now when tried to CSS animations in Chrome 42 ( which still requires -webkit- ). Now what ?

@pjlong
Copy link

pjlong commented May 1, 2015

@justnorris. Looks like @ahdinosaur's solution was working all along. You will have to upgrade to gulp-sass 2.x branch, however: npm install dlmanning/gulp-sass#2.x (and make sure to update to the most recent node-sass as well).

Here's the bare-bones implementation:

gulp.task('sass', function () {
    return gulp.src(paths.css.src_files)
        .pipe(sourcemaps.init())
            .pipe(sass())
        .pipe(sourcemaps.write())
        .pipe(sourcemaps.init({loadMaps: true}))
            .pipe(autoprefixer())
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(paths.css.dist));
});

Note: this is only for inline maps, I don't think I've successfully got external maps to work.

@clempat
Copy link

clempat commented May 1, 2015

From my side while debugging I saw that the sourcemap was overwritten because of the source file name different (for my case, first app.scss and then app.css)
That happened at this point:
https://github.com/mozilla/source-map/blob/master/lib/source-map/source-map-generator.js#L194

I still don't know how/where to fix it

@clempat
Copy link

clempat commented May 1, 2015

I would arrive to this solution: gulp-sourcemaps/vinyl-sourcemaps-apply@master...clempat:master Is that making sense to you ?

@pyronaur
Copy link

pyronaur commented May 6, 2015

Still doesn't work for me:

├── autoprefixer@5.1.1
├── browser-sync@2.7.1
├── coffee-script@1.9.2
├── connect@3.3.5
├── gulp@3.8.11
├── gulp-autoprefixer@2.2.0
├── gulp-coffee@2.3.1
├── gulp-concat@2.5.2
├── gulp-download@0.0.1
├── gulp-minify-css@1.1.1
├── gulp-notify@2.2.0
├── gulp-open@0.3.2
├── gulp-run@1.6.8
├── gulp-sass@2.0.0
├── gulp-shell@0.4.1
├── gulp-sourcemaps@1.5.2
├── gulp-uglifyjs@0.6.2
├── gulp-util@3.0.4
├── gulp-watch@4.2.4
├── gulp-wrap@0.11.0
├── merge-stream@0.1.7
└── node-sass@3.0.0
 npm -v
  2.7.4
node -v
  v0.12.2

Now I can't compile, I get:

[18:22:25] Starting 'sass'...

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: config
  1:1  invalid top-level expression

With this config:

    gulp.src("#{Config.sass.source}/app.sass")
        .pipe maps.init()
        .pipe sass
           indentedSyntax: true
           precision: 3,
           errLogToConsole: true
        .pipe maps.write()
        .pipe maps.init( loadMaps: true )
        .pipe autoprefixer()
        .pipe maps.write()
        .pipe gulp.dest(Config.build)

@clempat
Copy link

clempat commented May 6, 2015

is the comma after indentedSyntax: true not needed ? not so used to coffeescript ^^

@pyronaur
Copy link

pyronaur commented May 6, 2015

Nope :)
Actually the comma after precision: 3 is not needed too, looks messy, but works totally fine anyway.

@clempat
Copy link

clempat commented May 6, 2015

Are u sure it is connected to autoprefixer ? does pipe sass works alone ? Did u checked there: dlmanning/gulp-sass#55

@pyronaur
Copy link

pyronaur commented May 6, 2015

gulp-sass isn't just ready for production yet.

I ended up using gulp-ruby-sass with these settings:


    sass("#{Config.sass.source}/app.sass", {
        precision: 3
        style: 'expanded'
        sourcemap: true
    })
    .pipe autoprefixer()
    .pipe maps.write()
    .pipe gulp.dest(Config.build)

Works purrfectly.

@dsebastien
Copy link

@dmnplb Thanks, your solution works perfectly for me too: https://github.com/dsebastien/midnightLightV2/blob/master/gulp/tasks/styles.js

flect-miyake added a commit to flect-miyake/ng-boilerplate that referenced this issue Sep 14, 2015
autoprefixerでエラーが発生したため、sourcemapsの順番と設定を変更
[How to use in combination with gulp-sass](sindresorhus/gulp-autoprefixer#8
flect-miyake added a commit to flect-miyake/ng-boilerplate that referenced this issue Sep 14, 2015
autoprefixerでエラーが発生したため、sourcemapsの順番と設定を変更
sindresorhus/gulp-autoprefixer#8 を参考にした
@Jiasm
Copy link

Jiasm commented Oct 9, 2016

You just need to execute autoprefixer before sourcemap.

@englishextra
Copy link

this works for me:

/*!
 * npmjs.com/package/gulp-autoprefixer
 * const gulp = require('gulp');
 * const sourcemaps = require('gulp-sourcemaps');
 * const autoprefixer = require('gulp-autoprefixer');
 * const concat = require('gulp-concat');
 * gulp.task('default', () =>
 * gulp.src('src')
 * .pipe(sourcemaps.init())
 * .pipe(autoprefixer())
 * .pipe(concat('all.css'))
 * .pipe(sourcemaps.write('.'))
 * .pipe(gulp.dest('dest')));
 */
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var cleancss = require('gulp-clean-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var paths = {
	sass: ['./diy/libs/spa-englishextra/scss/**/*.scss']
};
gulp.task('default', ['sass']);
gulp.task('sass', function (done) {
	gulp.src('./diy/libs/spa-englishextra/scss/bundle.scss')
	.pipe(sass())
	.pipe(sourcemaps.init())
	.pipe(autoprefixer())
	.on('error', sass.logError)
	/* .pipe(gulp.dest('./diy/libs/spa-englishextra/css/')) */
	.pipe(cleancss({
			keepSpecialComments: 0
		}))
	.pipe(rename({
			extname: '-compiled.min.css'
		}))
	.pipe(sourcemaps.write('.'))
	.pipe(gulp.dest('./diy/libs/spa-englishextra/css/'))
	.on('end', done);
});
gulp.task('watch', function () {
	gulp.watch(paths.sass, ['sass']);
});
gulp.task('install', ['git-check'], function () {
	return bower.commands.install()
	.on('log', function (data) {
		gutil.log('bower', gutil.colors.cyan(data.id), data.message);
	});
});
gulp.task('git-check', function (done) {
	if (!sh.which('git')) {
		console.log(
			'  ' + gutil.colors.red('Git is not installed.'),
			'\n  Git, the version control system, is required to download Ionic.',
			'\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
			'\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.');
		process.exit(1);
	}
	done();
});

see here: https://www.npmjs.com/package/gulp-autoprefixer#source-maps

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

No branches or pull requests