-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
45 lines (36 loc) · 1.3 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const clean_css = require('gulp-clean-css');
const autoprefix = require('gulp-autoprefixer');
const plumber = require('gulp-plumber');
const rimraf = require("rimraf");
const path = require('path');
const size = require('gulp-size');
const sassVars = require('gulp-sass-variables');
const cssPrefix = require('./prefixer/gulp-css-selector-prefixer.js');
const plumeConfig = require('./plume.config.js');
const SOURCE_PATH = './sass';
const DIST_PATH = plumeConfig.targetDirName;
gulp.task('build', function() {
rimraf(path.join(__dirname, `${DIST_PATH}`), () => {});
let stream = gulp.src(`${SOURCE_PATH}/**/*.scss`)
.pipe(plumber(true))
.pipe(sassVars({$superclass: plumeConfig.superclass || ''}))
.pipe(sass({outputStyle: plumeConfig.outputStyle || 'compressed'}))
.pipe(clean_css())
.pipe(autoprefix())
.pipe(size())
if (plumeConfig.prefixer) {
stream = stream.pipe(cssPrefix(plumeConfig.prefixer))
}
return stream.pipe(gulp.dest(DIST_PATH));
});
gulp.task('watch', function(done) {
if (process.argv.includes('--watch')) {
console.log("Watching source directory, press Ctrl+C to exit");
gulp.watch(`${SOURCE_PATH}/**/*.scss`, gulp.series('build'));
} else {
done();
}
});
gulp.task('default', gulp.series('build', 'watch'));