-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
76 lines (66 loc) · 2.04 KB
/
gulpfile.js
File metadata and controls
76 lines (66 loc) · 2.04 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
const gulp = require("gulp"),
sass = require("gulp-sass"),
sassLint = require('gulp-sass-lint'),
clean = require('gulp-clean');
// set paths ...
const config = {
scssPath: "src/scss",
destPath: "application/static/stylesheets",
assetPath: "application/static/govuk-frontend/assets",
imgDestPath: "application/static/govuk_template/images"
}
// Tasks used to generate latest stylesheets
// =========================================
const cleanCSS = () =>
gulp
.src('application/static/stylesheets/**/*', {read: false})
.pipe(clean());
cleanCSS.description = `Delete old stylesheets files`;
// compile scss to CSS
const compileStylesheets = () =>
gulp
.src( config.scssPath + '/*.scss')
.pipe(sass({outputStyle: 'expanded',
includePaths: [ 'src/scss', 'src/govuk-frontend']}))
.on('error', sass.logError)
.pipe(gulp.dest(config.destPath));
// check .scss files against .sass-lint.yml config
const lintSCSS = () =>
gulp
.src('src/scss/**/*.s+(a|c)ss')
.pipe(sassLint({
files: {},
configFile: '.sass-lint.yml'
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError());
// Tasks for copying assets to application
// ======================================
const copyGovukStylesheets = () =>
gulp
.src('src/govuk/stylesheets/*')
.pipe(gulp.dest(config.destPath + "/govuk"));
const copyGovukAssets = () =>
gulp
.src('src/govuk-frontend/assets/**/*')
.pipe(gulp.dest(config.assetPath));
// Tasks to expose to CLI
// ======================
const latestStylesheets = gulp.series(
cleanCSS,
lintSCSS,
compileStylesheets,
gulp.parallel(
copyGovukStylesheets,
copyGovukAssets
)
);
latestStylesheets.description = `Generate the latest stylesheets`;
// Watch for scss changes
const watch = () => gulp.watch("src/scss/**/*", latestStylesheets);
watch.description = `Watch all project .scss for changes, then rebuild stylesheets.`;
// Set watch as default task
exports.default = watch;
exports.stylesheets = latestStylesheets;
exports.lintSCSS = lintSCSS;