-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
46 lines (40 loc) · 1.78 KB
/
Copy pathgulpfile.js
File metadata and controls
46 lines (40 loc) · 1.78 KB
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
'use strict';
var gulp = require('gulp');
var { execFile } = require('child_process');
gulp.task('css', function () {
var sass = require('gulp-sass')(require('sass'));
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
return gulp.src('./asset/sass/*.scss')
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(postcss([
autoprefixer(),
// Structural minification on top of Sass' whitespace compression:
// merges/dedupes rules and shortens values that `compressed` leaves.
// The default preset is rendering-safe and passes modern color syntax
// (oklch / color-mix / CSS masks) through untouched.
cssnano({ preset: 'default' })
]))
.pipe(gulp.dest('./asset/css'));
});
// Regenerate tokens.json (+ sibling-module copies and the DESIGN-SYSTEM.md
// tables) from _colors.scss — see scripts/build-tokens.js.
gulp.task('tokens', function (done) {
execFile(process.execPath, ['scripts/build-tokens.js'], function (err, stdout, stderr) {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
done(err);
});
});
gulp.task('css:watch', function () {
// A colour change must also regenerate tokens.json, otherwise watch mode
// silently drifts from the sibling modules' check-theme-tokens guards.
gulp.watch('./asset/sass/abstracts/variables/_colors.scss', gulp.series('tokens'));
gulp.watch('./asset/sass/**/*.scss', gulp.parallel('css'));
});
// `npm run start`: compile once first so a fresh checkout / branch switch
// never serves stale CSS, then watch.
gulp.task('default', gulp.series('css', 'css:watch'));