This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
129 lines (112 loc) · 3.56 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const gulp = require('gulp')
const nodemon = require('gulp-nodemon')
const plumber = require('gulp-plumber')
const livereload = require('gulp-livereload')
const sass = require('gulp-sass')
const path = require('path')
const replace = require('gulp-replace')
const fs = require('fs')
const rename = require('gulp-rename')
const repoRoot = path.join(__dirname, '/')
const govUkFrontendToolkitRoot = path.join(repoRoot, 'node_modules/govuk_frontend_toolkit/stylesheets')
const govUkElementRoot = path.join(repoRoot, 'node_modules/govuk-elements-sass/public/sass')
const assetsDirectory = './src/main/public'
const stylesheetsDirectory = `${assetsDirectory}/stylesheets`
gulp.task('sass', (done) => {
gulp.src(stylesheetsDirectory + '/*.scss')
.pipe(plumber())
.pipe(sass({
includePaths: [
govUkFrontendToolkitRoot,
govUkElementRoot
]
}))
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest(stylesheetsDirectory))
.pipe(livereload())
done()
})
gulp.task('copy-files', (done) => {
gulp.src([
'./node_modules/jquery/dist/jquery.min.js',
'./node_modules/govuk_frontend_toolkit/javascripts/**/*.js',
'./node_modules/govuk_template_jinja/assets/javascripts/**/*.js'
])
.pipe(gulp.dest(`${assetsDirectory}/js/lib/`))
gulp.src([
'./node_modules/@hmcts/cmc-common-frontend/macros/*.njk'
])
.pipe(gulp.dest(`${assetsDirectory}/macros`))
gulp.src([
'./node_modules/HTML_CodeSniffer/HTMLCS.js'
])
.pipe(gulp.dest(`${assetsDirectory}/js/lib/htmlcs`))
gulp.src([
'./node_modules/HTML_CodeSniffer/Standards/**'
])
.pipe(gulp.dest(`${assetsDirectory}/js/lib/htmlcs/Standards`))
gulp.src([
'./node_modules/HTML_CodeSniffer/Auditor/HTMLCSAuditor.js'
])
.pipe(gulp.dest(`${assetsDirectory}/js/lib/htmlcs/Auditor`))
gulp.src([
'./node_modules/HTML_CodeSniffer/Auditor/**/*.{css,gif,png}'
])
.pipe(gulp.dest(`${assetsDirectory}/stylesheets/lib/`))
gulp.src([
'./node_modules/govuk_template_jinja/assets/images/apple-touch-icon.png'
])
.pipe(gulp.dest(`${assetsDirectory}/`))
gulp.src([
'./node_modules/govuk_frontend_toolkit/images/**/*',
'./node_modules/govuk_template_jinja/assets/images/*.*'
])
.pipe(gulp.dest(`${assetsDirectory}/img/lib/`))
gulp.src([
'./node_modules/govuk_template_jinja/assets/stylesheets/**/*'
])
.pipe(replace('images/', '/stylesheets/lib/images/', { skipBinary: true }))
.pipe(gulp.dest(`${assetsDirectory}/stylesheets/lib/`))
gulp.src('./node_modules/nodelist-foreach-polyfill/index.js')
.pipe(rename('nodelist-foreach-polyfill.js'))
.pipe(gulp.dest(`${assetsDirectory}/js/lib/`))
done()
})
gulp.task('watch', (done) => {
gulp.watch(stylesheetsDirectory + '/**/*.scss', gulp.series('sass'))
done()
})
gulp.task('develop', (done) => {
setTimeout(() => {
livereload.listen({
key: fs.readFileSync(path.join(__dirname, 'src', 'main', 'resources', 'localhost-ssl', 'localhost.key'), 'utf-8'),
cert: fs.readFileSync(path.join(__dirname, 'src', 'main', 'resources', 'localhost-ssl', 'localhost.crt'), 'utf-8'),
})
nodemon({
ext: 'ts js po',
stdout: true
}).on('readable', () => {
this.stdout.on('data', function (chunk) {
if (/^Application started on port/.test(chunk)) {
livereload.changed(__dirname)
}
})
this.stdout.pipe(process.stdout)
this.stderr.pipe(process.stderr)
})
}, 500)
done()
})
gulp.task('default',
gulp.series(
gulp.parallel(
'sass',
'copy-files',
),
gulp.parallel(
'develop',
'watch'
)
)
)