-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
62 lines (53 loc) · 1.72 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
57
58
59
60
61
62
"use strict";
import path from "path";
import { fileURLToPath } from "url";
import gulp from "gulp";
import gulpSass from "gulp-sass";
import { deleteAsync } from "del";
import dartSass from "sass";
const sass = gulpSass(dartSass)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PROJECT_DIR = path.resolve(__dirname);
const SASS_FILES = `${PROJECT_DIR}/frontend/sass/**/*.scss`;
const JS_FILES = `${PROJECT_DIR}/frontend/js/**/*.js`;
const STATIC_DIR = `${PROJECT_DIR}/static`;
const CSS_DIR = `${STATIC_DIR}/css`;
const CSS_FILES = `${CSS_DIR}/**/*.css`;
const CSS_MAPS = `${CSS_DIR}/**/*.css.map`;
const GOVUK_PATH = `${PROJECT_DIR}/node_modules/govuk-frontend/govuk`;
const GOVUK_ASSETS_PATH = `${GOVUK_PATH}/assets`;
const ASSETS_DEST = `${STATIC_DIR}/assets`;
const JS_DEST = `${STATIC_DIR}/js`;
const sassOptions = {
// includePaths: ['./conf/'],
outputStyle: "compressed",
};
gulp.task("clean", function () {
const fonts = `${ASSETS_DEST}/fonts`;
return deleteAsync([CSS_FILES, CSS_MAPS, fonts]);
});
gulp.task("copy-govuk-assets", function () {
return gulp
.src([`${GOVUK_ASSETS_PATH}/**/*`], { base: GOVUK_ASSETS_PATH })
.pipe(gulp.dest(ASSETS_DEST));
});
gulp.task("copy-govuk-js", function () {
return gulp
.src([JS_FILES, `${GOVUK_PATH}/all.js`])
.pipe(gulp.dest(JS_DEST));
});
gulp.task("sass:compile", function () {
return gulp
.src(SASS_FILES)
.pipe(sass(sassOptions))
.pipe(gulp.dest(CSS_DIR));
});
gulp.task("sass:watch", function () {
gulp.watch([SASS_FILES], gulp.series("sass:compile"));
});
gulp.task("sass", gulp.series("clean", "sass:compile"));
gulp.task(
"default",
gulp.series(["sass", "copy-govuk-assets", "copy-govuk-js"])
);