-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
46 lines (39 loc) · 1.14 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
// Gulp workflow from: https://www.sitepoint.com/simple-gulpy-workflow-sass/
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var del = require('del');
var input = './scss/**/*.scss';
var output = './dist/css';
var sassOptions = {
errLogToConsole: true,
outputStyle: 'compressed'
};
// Clean
gulp.task('clean', function() {
return del('dist/**', {force:true})
.then(paths => {
console.log('Deleted files and folders:\n', paths.join('\n'))
});
});
// Sass
gulp.task('sass', function() {
return gulp
.src(input)
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer())
.pipe(gulp.dest(output))
});
// Watch
gulp.task('watch', function() {
return gulp
.watch(input, ['clean', 'sass'])
.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
})
});
// Default
gulp.task('default', ['sass', 'watch']);