This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
executable file
·102 lines (90 loc) · 2 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
'use strict';
const gulp = require('gulp');
const del = require('del');
const merge = require('merge-stream');
const styles = require('./tasks/styles');
const scripts = require('./tasks/scripts');
const vendors = require('./tasks/vendors');
const single = require('./tasks/single');
const serve = require('./tasks/serve');
const prepare = require('./tasks/prepare');
const icons = require('./tasks/icons');
const config = require('./tasks/config');
/**
* Clean
*
* Removes the build directory. Avoids issues with deleted files.
*/
const clean = () => del([`${config.project}/${config.dest}`], {force: true});
/**
* Config
*/
let copyPaths = [{
src: 'images/**/*',
dest: '/images',
}, {
src: 'svg/**/*.svg',
dest: '/svg',
}, {
src: 'favicons/**/*',
dest: '/favicons',
}, {
src: 'fonts/**/*',
dest: '/fonts',
}];
const copyPathsDev = [{
src: 'components/**/!(*.scss)',
dest: '/components',
}, {
root: true,
src: 'docs/**/*.{md,html}',
dest: '/docs',
}];
if (config.dev || config.styleguide) {
copyPaths.push(...copyPathsDev);
}
/**
* Copy stuff
*/
const copyAssets = () => {
return merge(copyPaths.map((item) => {
const baseDir = item.root ? '' : config.src;
return gulp.src(baseDir + item.src, {cwd: config.project})
.pipe(gulp.dest(config.dest + item.dest, {cwd: config.project}));
}));
};
/**
* Prepare styleguide if needed
*/
const prepareStyleguide = (done) => {
if (config.dev || config.styleguide) {
prepare();
}
done();
}
/**
* Gulp Tasks
*/
const build = gulp.series(
clean,
gulp.parallel(
styles,
scripts,
copyAssets,
vendors,
single,
icons,
prepareStyleguide,
),
);
gulp.task('serve', gulp.series(build, serve));
gulp.task('prepare', prepare);
gulp.task('build', build);
gulp.task('clean', clean);
gulp.task('copy-assets', copyAssets);
gulp.task('styles', styles);
gulp.task('scripts', scripts);
gulp.task('vendors', vendors);
gulp.task('icons', icons);
gulp.task('single', gulp.series(single));
gulp.task('default', build);