-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
52 lines (46 loc) · 1.32 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @file
* Gulpfile for compiling Sass.
*/
// https://css-tricks.com/gulp-for-beginners/
const gulp = require('gulp');
// Requires the gulp-sass plugin
const sass = require('gulp-sass')(require('sass'));
// Create sass sourcemaps
const sourcemaps = require('gulp-sourcemaps');
// Delete generated files when needed
const del = require('del');
// Run a list of tasks in order
const runSequence = require('run-sequence');
const autoprefixer = require('gulp-autoprefixer');
// Used to set whether CSS format is compressed or expanded when compiled.
const plumber = require('gulp-plumber');
// Used to catch errors and continue build
let style = 'compressed';
gulp.task('sass', () => gulp.src('sass/**/*.scss')
.pipe(plumber(function(error){
console.log(error.message);
this.emit('end');
}))
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: style })) // Converts Sass to CSS with gulp-sass.
.pipe(autoprefixer())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('css')));
gulp.task('clean:css', (cb) => {
del.sync('css/*')
cb();
});
gulp.task('watch', () => {
gulp.watch('sass/**/*.scss', gulp.series('sass'));
});
// One time build process.
gulp.task('build', (cb) => {
runSequence('clean:css', 'sass');
cb();
});
gulp.task('build-unminified', (cb) => {
style = 'expanded';
runSequence('build');
cb();
});