-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·114 lines (105 loc) · 2.28 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
const gulp = require('gulp');
const minify = require('gulp-minify');
const preprocess = require('gulp-preprocess');
const prettyData = require('gulp-pretty-data');
const clean = require('gulp-clean');
const newer = require('gulp-newer');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
const configuredExtensions = [];
gulp.task('js', () => {
configuredExtensions.push('js');
return gulp
.src([
'src/**/*.js',
'!src/**/node_modules/',
'!src/**/node_modules/**/*'
])
.pipe(newer('bin'))
.pipe(preprocess())
.pipe(
minify({
ext: {
min: '.js'
},
noSource: true
})
)
.pipe(gulp.dest('bin'));
});
gulp.task('ts', () => {
configuredExtensions.push('ts');
return gulp
.src([
'src/**/*.ts',
'!src/**/node_modules/',
'!src/**/node_modules/**/*'
])
.pipe(newer('bin'))
.pipe(preprocess())
.pipe(tsProject())
.pipe(
minify({
ext: {
min: '.js'
},
noSource: true
})
)
.pipe(gulp.dest('bin'));
});
gulp.task('images', () => {
configuredExtensions.push('png');
configuredExtensions.push('jpg');
configuredExtensions.push('jpeg');
configuredExtensions.push('gif');
configuredExtensions.push('tif');
return gulp
.src([
'src/**/*.{png,jpg,jpeg,gif,tif}',
'!src/**/node_modules/',
'!src/**/node_modules/**/*'
])
.pipe(newer('bin'))
.pipe(gulp.dest('bin'));
});
gulp.task('pretty-data', () => {
configuredExtensions.push('xml');
configuredExtensions.push('json');
configuredExtensions.push('xlf');
configuredExtensions.push('svg');
return gulp
.src([
'src/**/*.{xml,json,xlf,svg}',
'!src/**/node_modules/',
'!src/**/node_modules/**/*'
])
.pipe(newer('bin'))
.pipe(
prettyData({
type: 'minify',
preserveComments: false
})
)
.pipe(gulp.dest('bin'));
});
gulp.task('copy', () => {
return gulp
.src([
'src/**/*',
`!src/**/*.{${configuredExtensions.join(',')}}`,
'!src/**/node_modules/',
'!src/**/node_modules/**/*'
])
.pipe(newer('bin'))
.pipe(gulp.dest('bin'));
});
gulp.task('clean', () => {
return gulp.src('bin').pipe(clean());
});
gulp.task(
'default',
gulp.parallel('js', 'ts', 'images', 'pretty-data', 'copy')
);
gulp.task('build', gulp.series('default'));
gulp.task('rebuild', gulp.series('clean', 'default'));