-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
40 lines (36 loc) · 1.25 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
const gulp = require('gulp');
const gulpAutoprefixer = require('gulp-autoprefixer');
const plumber = require('gulp-plumber');
const purgeSourcemaps = require('gulp-purge-sourcemaps');
const rename = require('gulp-rename');
const sass = require('gulp-sass')(require('sass'));
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
const postcsspxv = require('postcss-pxv');
const sassOutDir = './test';
const sassSrcDir = ['./test/test.scss'];
const sassWatchDir = [
'./scss/**/*.css',
'./scss/**/*.sass',
'./scss/**/*.scss',
'./test/**/*.sass',
'./test/**/*.scss',
];
gulp.task('build-sass', async function () {
return await gulp
.src(sassSrcDir)
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(purgeSourcemaps())
.pipe(plumber())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(rename((path) => (path.basename = 'test')))
.pipe(gulpAutoprefixer())
.pipe(sourcemaps.write())
.pipe(postcss([postcsspxv]))
.pipe(gulp.dest(sassOutDir));
});
gulp.task('watch-sass', async function () {
return await gulp.watch(sassWatchDir, gulp.series('build-sass'));
});
gulp.task('build', gulp.series('build-sass'));
gulp.task('default', gulp.series('watch-sass', 'build-sass'));