-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (49 loc) · 1.54 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
53
54
55
56
const gulp = require('gulp');
const size = require('gulp-size');
const sass = require('gulp-sass')(require('sass'));
const postcss = require('gulp-postcss');
const autoprefixer = require('autoprefixer');
const rename = require('gulp-rename');
const csso = require('gulp-csso');
const adjustMQ = require('postcss-sort-media-queries');
const gzip = require('gulp-gzip');
const gulpBrotli = require('gulp-brotli');
const zlib = require('zlib');
var replace = require('gulp-replace');
function cloneSASS(callback) {
gulp.src('./src/agrid/scss/**/*.scss')
.pipe(gulp.dest('./dist/scss'));
callback();
}
function buildCSS(callback) {
gulp.src('./src/agrid/scss/*.scss')
.pipe(sass().on("error", sass.logError))
.pipe(size({ showFiles: true }))
.pipe(postcss([autoprefixer(), adjustMQ()]))
.pipe(csso())
.pipe(rename({
extname: '.min.css'
}))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('./dist'))
callback();
}
function compressGZ(callback) {
gulp.src('./dist/*.min.css')
.pipe(gzip())
.pipe(gulp.dest('./dist'));
callback();
}
function compressBR(callback) {
const brotliOpts = {
params: {
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
},
}
gulp.src('./dist/*.min.css')
.pipe(gulpBrotli.compress(brotliOpts))
.pipe(gulp.dest('./dist'));
callback();
}
exports.build = gulp.series(cloneSASS, buildCSS);
exports.compress = gulp.parallel(compressGZ, compressBR)