-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
39 lines (36 loc) · 1.1 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
// Defining requirements
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const sass = require('gulp-sass');
const cssnano = require('gulp-cssnano');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const gulpSequence = require('gulp-sequence');
// gulp sourcemaps + sass
gulp.task('scss', () => {
gulp.src('./scss/*.scss')
.pipe(plumber({
errorHandler(err) {
console.log(err);
this.emit('end');
},
}))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sass())
.pipe(sourcemaps.write(undefined, { sourceRoot: null }))
.pipe(gulp.dest('./css'));
});
// Minifies CSS files
gulp.task('min', () => gulp.src('./css/default.css')
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(plumber({
errorHandler(err) {
console.log(err);
this.emit('end');
},
}))
.pipe(rename({ suffix: '.min' }))
.pipe(cssnano({ discardComments: { removeAll: true } }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./css/')));
gulp.task('build', (callback) => { gulpSequence('scss', 'min')(callback); });