forked from slovensko-digital/navody-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
141 lines (126 loc) · 3.35 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
130
131
132
133
134
135
136
137
138
139
140
141
'use strict'
const paths = require('./config/paths.json')
const gulp = require('gulp')
const taskListing = require('gulp-task-listing')
const runsequence = require('run-sequence')
const taskArguments = require('./tasks/gulp/task-arguments')
const nodemon = require('nodemon')
const concat = require('gulp-concat')
// Gulp sub-tasks
require('./tasks/gulp/clean.js')
require('./tasks/gulp/lint.js')
require('./tasks/gulp/compile-assets.js')
require('./tasks/gulp/watch.js')
// new tasks
require('./tasks/gulp/copy-to-destination.js')
require('./tasks/gulp/asset-version.js')
require('./tasks/gulp/sassdoc.js')
const external = {
scripts: [
'lib/replace-diacritics.js',
'lib/slovak-municipalities.js',
'node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js'
],
styles: [
'node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.css'
]
}
// Umbrella scripts tasks for preview ---
// Runs js lint and compilation
// --------------------------------------
gulp.task('scripts', cb => {
runsequence('js:compile', cb)
})
// Umbrella styles tasks for preview ----
// Runs js lint and compilation
// --------------------------------------
gulp.task('styles', cb => {
runsequence('scss:lint', 'scss:compile', cb)
})
// Copy assets task ----------------------
// Copies assets to taskArguments.destination (public)
// --------------------------------------
gulp.task('copy:assets', () => {
return gulp.src(paths.src + 'assets/**/*')
.pipe(gulp.dest(taskArguments.destination + '/assets/'))
})
gulp.task('external-scripts', () => {
return gulp.src(external.scripts)
.pipe(concat('libs.js'))
.pipe(gulp.dest(taskArguments.destination + '/'))
})
gulp.task('external-styles', () => {
return gulp.src(external.styles)
.pipe(concat('libs.css'))
.pipe(gulp.dest(taskArguments.destination + '/'))
})
// All test combined --------------------
// Runs js, scss and accessibility tests
// --------------------------------------
gulp.task('test', cb => {
runsequence(
'scss:lint',
'scss:compile',
cb
)
})
// Copy assets task for local & heroku --
// Copies files to
// taskArguments.destination (public)
// --------------------------------------
gulp.task('copy-assets', cb => {
runsequence(
'styles',
'scripts',
'external-scripts',
'external-styles',
cb
)
})
// Dev task -----------------------------
// Runs a sequence of task on start
// --------------------------------------
gulp.task('dev', cb => {
runsequence(
'clean',
'copy-assets',
'sassdoc',
'serve',
cb
)
})
// Serve task ---------------------------
// Restarts node app when there is changed
// affecting js, css or njk files
// --------------------------------------
gulp.task('serve', ['watch'], () => {
return nodemon({
script: 'app/start.js'
})
})
// Build package task -----------------
// Prepare package folder for publishing
// -------------------------------------
gulp.task('build:package', cb => {
runsequence(
'clean',
'copy-files',
'js:compile',
'external-scripts',
'external-styles',
cb
)
})
gulp.task('build:dist', cb => {
runsequence(
'clean',
'copy-assets',
'copy:assets',
'update-assets-version',
cb
)
})
// Default task -------------------------
// Lists out available tasks.
// --------------------------------------
gulp.task('default', taskListing)