-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
71 lines (54 loc) · 1.44 KB
/
gulpfile.ts
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
import gulp from 'gulp'
import changed from 'gulp-changed'
import minify from 'gulp-minify'
import gulpSass from 'gulp-sass'
import * as dartSass from 'sass'
const sass = gulpSass(dartSass)
/*
* Compile SASS
*/
const publicSCSSDestination = 'public/stylesheets'
function publicSCSSFunction(): NodeJS.ReadWriteStream {
return gulp
.src('public-scss/*.scss')
.pipe(
sass({ outputStyle: 'compressed', includePaths: ['node_modules'] }).on(
'error',
sass.logError
)
)
.pipe(gulp.dest(publicSCSSDestination))
}
gulp.task('public-scss', publicSCSSFunction)
/*
* Minify public/javascripts
*/
const publicJavascriptsDestination = 'public/javascripts'
function publicJavascriptsMinFunction(): NodeJS.ReadWriteStream {
return gulp
.src('public-typescript/*.js', { allowEmpty: true })
.pipe(
changed(publicJavascriptsDestination, {
extension: '.min.js'
})
)
.pipe(minify({ noSource: true, ext: { min: '.min.js' } }))
.pipe(gulp.dest(publicJavascriptsDestination))
}
gulp.task('public-javascript-min', publicJavascriptsMinFunction)
/*
* Watch
*/
function watchFunction(): void {
gulp.watch('public-scss/*.scss', publicSCSSFunction)
gulp.watch('public-typescript/*.js', publicJavascriptsMinFunction)
}
gulp.task('watch', watchFunction)
/*
* Initialize default
*/
gulp.task('default', () => {
publicJavascriptsMinFunction()
publicSCSSFunction()
watchFunction()
})