forked from year-calendar/js-year-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (40 loc) · 1.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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const babel = require('gulp-babel');
const less = require('gulp-less');
const uglify = require('gulp-uglify');
const cleanCss = require('gulp-clean-css');
const rename = require('gulp-rename');
const compileTS = function() {
const tsProject = ts.createProject('tsconfig.json');
// Use to generate the definition type
return gulp.src('src/ts/**/*.ts')
.pipe(tsProject())
.dts
.pipe(gulp.dest('dist'));
}
const exportJS = function() {
return gulp.src('src/ts/js-year-calendar.ts')
.pipe(babel())
.pipe(gulp.dest('dist'));
}
const minifyJS = function() {
return gulp.src('dist/js-year-calendar.js')
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('dist'));
}
const scripts = gulp.series(compileTS, exportJS, minifyJS);
const styles = function() {
return gulp.src('src/less/js-year-calendar.less')
.pipe(less())
.pipe(gulp.dest('dist'))
.pipe(rename({ suffix: '.min' }))
.pipe(cleanCss())
.pipe(gulp.dest('dist'));
}
gulp.task('build', gulp.series(scripts, styles));
gulp.task('watch', function () {
gulp.watch('src/ts/**/*.ts', scripts);
gulp.watch('src/less/**/*.less', styles);
});