-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
113 lines (99 loc) · 2.88 KB
/
gulpfile.js
File metadata and controls
113 lines (99 loc) · 2.88 KB
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
'use strict';
const gulp = require('gulp'),
sass = require('gulp-sass')(require('sass')),
typescript = require('gulp-typescript'),
rimraf = require('rimraf'),
tsProject = typescript.createProject('tsconfig.json'),
exec = require('child_process').exec;
var path = {
build: {
html: 'build/',
examples: 'build/examples/',
ts: 'lib/',
css: 'build/css/',
img: 'build/img/',
fonts: 'build/fonts/'
},
src: {
html: 'src/*.html',
examples: 'src/examples/**/*.jsonc',
ts: 'src/ts/**/*.ts',
style: 'src/sass/index.scss',
img: 'src/img/**/*.*',
fonts: 'src/fonts/**/*.*'
},
watch: {
html: 'src/**/*.html',
examples: 'src/examples/**/*.jsonc',
ts: 'src/ts/**/*.ts',
js: 'src/index.js',
style: 'src/sass/**/*.scss',
img: 'src/img/**/*.*',
fonts: 'src/fonts/**/*.*'
},
clean: './build'
};
gulp.task('html:build', function () {
return gulp.src(path.src.html)
.pipe(gulp.dest(path.build.html));
});
gulp.task('ts:build', function () {
return gulp.src(path.src.ts)
.pipe(tsProject(typescript.reporter.defaultReporter())).js
.pipe(gulp.dest(path.build.ts));
});
gulp.task('bundle:build', function (cb) {
exec('npm run bundle', function (err, stderr, stdout) {
console.log(stderr);
console.log(stdout);
cb(err);
});
});
gulp.task('examples:build', function () {
return gulp.src(path.src.examples)
.pipe(gulp.dest(path.build.examples));
});
gulp.task('style:build', function () {
return gulp.src(path.src.style)
.pipe(sass())
.pipe(gulp.dest(path.build.css));
});
gulp.task('image:build', function () {
return gulp.src(path.src.img)
.pipe(gulp.dest(path.build.img));
});
gulp.task('favicon:build', function () {
return gulp.src('src/favicon.ico')
.pipe(gulp.dest(path.build.html));
});
gulp.task('fonts:build', function() {
return gulp.src(path.src.fonts)
.pipe(gulp.dest(path.build.fonts));
});
gulp.task('build', gulp.series(
'ts:build',
'bundle:build',
'html:build',
'examples:build',
'style:build',
'fonts:build',
'image:build',
'favicon:build'
));
gulp.task('clean', function (cb) {
rimraf(path.clean, cb);
});
gulp.task('watch', function () {
gulp.watch([path.watch.html], gulp.series('html:build'));
gulp.watch([path.watch.style], gulp.series('style:build'));
gulp.watch([path.watch.ts], gulp.series('ts:build', 'bundle:build'));
gulp.watch([path.watch.js], gulp.series('bundle:build'));
gulp.watch([path.watch.examples], gulp.series('examples:build'));
gulp.watch([path.watch.img], gulp.series('image:build'));
gulp.watch([path.watch.fonts], gulp.series('fonts:build'));
});
gulp.task('run', gulp.series(
'clean',
'build',
'watch'
));