-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.ts
83 lines (69 loc) · 1.51 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
72
73
74
75
76
77
78
79
80
81
82
83
'use strict'
import * as gulp from 'gulp'
import * as gulpLoadPlugins from 'gulp-load-plugins'
import * as browserSyncLib from 'browser-sync'
import * as minimist from 'minimist'
import * as pjson from './package.json'
import { jsWatch } from './gulp/config/shared-vars'
import createTasks from './gulp/tasks/auto-imports'
// Load all gulp plugins based on their names
// EX: gulp-copy -> copy
const plugins = gulpLoadPlugins()
const defaultNotification = function (err) {
return {
subtitle: err.plugin,
message: err.message,
sound: 'Funk',
onLast: true,
}
}
let config = { ...pjson.config, ...defaultNotification }
let args = minimist(process.argv.slice(2))
let dirs = config.directories
let taskTarget = args.production ? dirs.destination : dirs.temporary
// Create a new browserSync instance
let browserSync = browserSyncLib.create()
createTasks(gulp, plugins, args, config, taskTarget, browserSync)
// Compiles all the code
gulp.task(
'compile',
gulp.series(
gulp.parallel(
'copy',
'pug',
'imagemin',
'sass',
'modernizr',
'browserify'
)
)
)
// Default task
gulp.task(
'default',
gulp.series(
'clean',
(done) => {
jsWatch.isEnabled = true
done()
},
'compile',
'watch' //watch holds browsersync
)
)
// Build production-ready code
gulp.task(
'build',
gulp.series(
'clean',
(done) => {
jsWatch.isEnabled = false
done()
},
'compile'
)
)
// Server tasks with watch
gulp.task('serve', gulp.series('default'))
// Testing
gulp.task('test', gulp.series('eslint'))