Last active
June 9, 2016 11:25
-
-
Save FuruholmAnton/a40ba79ab88c6b586c4a201268fe04b3 to your computer and use it in GitHub Desktop.
SASS Gulp file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var sassdoc = require('sassdoc'); | |
var input = './assets/scss/**/*.scss'; | |
var output = './assets/css'; | |
var sassOptions = { | |
errLogToConsole: true, | |
outputStyle: 'expanded' | |
}; | |
var autoprefixerOptions = { | |
browsers: ['last 2 versions', '> 5%', 'Firefox ESR'] | |
}; | |
gulp.task('sass', function () { | |
return gulp | |
.src(input) | |
.pipe(sourcemaps.init()) | |
.pipe(sass(sassOptions).on('error', sass.logError)) | |
.pipe(sourcemaps.write('./assets/css')) | |
.pipe(autoprefixer(autoprefixerOptions)) | |
.pipe(gulp.dest(output)); | |
}); | |
var sassdocOptions = { | |
dest: './public/sassdoc' | |
}; | |
gulp.task('sassdoc', function () { | |
return gulp | |
.src(input) | |
.pipe(sassdoc(sassdocOptions)) | |
.resume(); | |
}); | |
gulp.task('watch', function() { | |
return gulp | |
// Watch the input folder for change, | |
// and run `sass` task when something happens | |
.watch(input, ['sass']) | |
// When there is a change, | |
// log a message in the console | |
.on('change', function(event) { | |
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); | |
}); | |
}); | |
gulp.task('default', ['sass', 'watch' /*, possible other tasks... */]); | |
gulp.task('prod', ['sassdoc'], function () { | |
return gulp | |
.src(input) | |
.pipe(sass({ outputStyle: 'compressed' })) | |
.pipe(autoprefixer(autoprefixerOptions)) | |
.pipe(gulp.dest(output)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.