-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (64 loc) · 1.88 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
var gulp = require('gulp');
var less = require('gulp-less');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var cleancss = require('gulp-clean-css');
var rename = require('gulp-rename');
var ts = require('gulp-typescript');
var srcPaths = {
typescript: [
'public/source/ts/*.ts',
'public/source/dts/*.ts'
],
themes: {
modern: 'public/assets/themes/modern/less/*.less',
legacy: 'public/assets/themes/legacy/less/*.less'
}
};
var destPaths = {
scripts: 'public/build/js',
themes: {
modern: 'public/assets/themes/modern',
legacy: 'public/assets/themes/legacy'
}
};
var tsProject = ts.createProject({
declarationFiles: true,
noResolve: true,
target: "es5",
module: "commonjs",
declaration: false,
noImplicitAny: false,
removeComments: true
});
function minifyLess(src, dest) {
gulp.src(src)
.pipe(sourcemaps.init())
.pipe(less())
.pipe(cleancss())
.pipe(rename({ extname: ".min.css" }))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(dest));
}
gulp.task('typescript', function() {
var tsResult = gulp.src(srcPaths.typescript)
.pipe(sourcemaps.init())
.pipe(tsProject('defaultReporter'));
return tsResult.js
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(destPaths.scripts));
});
gulp.task('themes', function() {
for (var theme in srcPaths.themes) {
minifyLess(srcPaths.themes[theme], destPaths.themes[theme]);
}
});
gulp.task('watch', function() {
gulp.watch(srcPaths.typescript, ['typescript']);
gulp.watch(srcPaths.themes.modern, ['themes']);
gulp.watch(srcPaths.themes.legacy, ['themes']);
});
gulp.task('default', ['typescript', 'themes']);
gulp.task('do-watch', ['default', 'watch']);