forked from ministryofjustice/fala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (49 loc) · 1.67 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
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const concat = require('gulp-concat');
const terser = require('gulp-terser');
const cleanCss = require('gulp-clean-css');
const sass = require('gulp-sass');
const { src, parallel, dest} = require('gulp');
// FALA js & GOVUK js - copying over both if we ever want to add custom js
const jsPath = [
'fala/assets-src/scripts/main.js',
'node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js'
];
// FALA css & GOVUK css - beacuse we import GOVUK scss into same file in order to overide/add to GOVUK classes
const cssPath = 'fala/assets-src/sass/*.scss';
// GOVUK font & images only - because we have no FALA assets anymore
const assetPath = 'node_modules/govuk-frontend/dist/govuk/assets/**';
function jsTask() {
return src(jsPath)
.pipe(sourcemaps.init())
// name of output file
.pipe(concat('all.js'))
// a JavaScript mangler/compressor toolkit for ES6+
.pipe(terser())
.pipe(sourcemaps.write('.'))
// destination of new files
.pipe(dest('fala/assets/js'));
}
function cssTask() {
return src(cssPath)
.pipe(sourcemaps.init())
.pipe(sass())
// name of output file
.pipe(concat('style.css'))
// this minifies the CSS
.pipe(cleanCss())
.pipe(sourcemaps.write('.'))
// destination of new files
.pipe(dest('fala/assets/css'));
}
function assetTask() {
// { encoding: false } to copy over as binary files, GULP default is to encode into UTF:8
return src(assetPath, { encoding: false })
.pipe(dest('fala/assets'));
}
exports.jsTask = jsTask;
exports.cssTask = cssTask;
exports.assetTask = assetTask;
// build/execute the tasks
exports.build = parallel(jsTask, cssTask, assetTask);