Merge pull request #46 from akkolad/master
Add 3 tasks for sass in gulpfile.js
This commit is contained in:
commit
18027b7d7d
45
gulpfile.js
45
gulpfile.js
|
@ -30,10 +30,55 @@ var uglify = require('gulp-uglify');
|
|||
var merge2 = require('merge2');
|
||||
var ignore = require('gulp-ignore');
|
||||
var rimraf = require('gulp-rimraf');
|
||||
var clone = require('gulp-clone');
|
||||
var merge = require('gulp-merge');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var browserSync = require('browser-sync').create();
|
||||
var reload = browserSync.reload;
|
||||
|
||||
|
||||
// Run:
|
||||
// gulp sass + cssnano + rename
|
||||
// Prepare the min.css for production (with 2 pipes to be sure that "child-theme.css" == "child-theme.min.css")
|
||||
gulp.task('scss-for-prod', function() {
|
||||
var source = gulp.src('./sass/*.scss')
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(sass());
|
||||
|
||||
var pipe1 = source.pipe(clone())
|
||||
.pipe(sourcemaps.write(undefined, { sourceRoot: null }))
|
||||
.pipe(gulp.dest('./css'));
|
||||
|
||||
var pipe2 = source.pipe(clone())
|
||||
.pipe(cssnano())
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest('./css'));
|
||||
|
||||
return merge(pipe1, pipe2);
|
||||
});
|
||||
|
||||
|
||||
// Run:
|
||||
// gulp sourcemaps + sass + reload(browserSync)
|
||||
// Prepare the child-theme.css for the developpment environment
|
||||
gulp.task('scss-for-dev', function() {
|
||||
gulp.src('./sass/*.scss')
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(sass())
|
||||
.pipe(sourcemaps.write(undefined, { sourceRoot: null }))
|
||||
.pipe(gulp.dest('./css'))
|
||||
.pipe(reload({stream: true}));
|
||||
});
|
||||
|
||||
gulp.task('watch-scss', ['browser-sync'], function () {
|
||||
gulp.watch('./sass/**/*.scss', ['scss-for-dev']);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// Run:
|
||||
// gulp sass
|
||||
// Compiles SCSS files in CSS
|
||||
|
|
Reference in New Issue