-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (49 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
const {
task,
src,
dest,
series,
} = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const browserify = require('browserify');
const babelify = require('babelify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const assetsPath = './static/';
const pathToGovFrontend = './node_modules/govuk-frontend/govuk';
const pathToNhsFrontend = './node_modules/nhsuk-frontend/dist';
// -------- Assets
task('build-assets-sass', () => src(['app/assets/sass/*.scss'])
.pipe(sass
.sync()
.on('error', sass.logError))
.pipe(dest(`${assetsPath}/css`)));
task('build-govuk-js', () => src([`${pathToGovFrontend}/all.js`])
.pipe(dest(`${assetsPath}/js`)));
task('build-nhs-js', () => src([`${pathToNhsFrontend}/nhsuk-*.min.js`])
.pipe(rename('nhsuk.js'))
.pipe(dest(`${assetsPath}/js`)));
task('build-assets', () => src([`${pathToGovFrontend}/assets/**/*`])
.pipe(dest(`${assetsPath}/assets`)));
task('build-project-js', () => src(['./app/assets/js/*.js'])
.pipe(uglify())
.pipe(dest(`${assetsPath}/js`)));
task('build-project-js-bundle', () => {
const filesToBundle = ['./app/assets/js/time-out.js'];
return browserify([...filesToBundle])
.transform(babelify, {
presets: ['@babel/preset-env'],
sourceMaps: true,
global: true,
ignore: [/\/node_modules\/(?!hmrc-frontend\/)/],
})
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(dest(`${assetsPath}/js`));
});
// --- Series
task('build', series(['build-assets-sass', 'build-nhs-js', 'build-assets', 'build-govuk-js', 'build-project-js', 'build-project-js-bundle']));