-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
71 lines (59 loc) · 1.86 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
const del = require('del');
const gulp = require('gulp');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const rename = require('gulp-rename');
const order = require('gulp-order');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
var targetName = 'comfortable';
var mainTsSrc = [ 'src/main/ts/**/*.ts' ];
var mainCssSrc = [ 'src/main/ts/**/*.css' ];
var build = 'lib';
var mainTsProject = ts.createProject({
noImplicitAny : true,
declaration : true,
stripInternal : true,
removeComments : true,
outFile : `${targetName}.js`
});
gulp.task('clean', function() {
return del([ `${build}/*` ]);
});
gulp.task('build-main', function() {
return gulp.src(mainTsSrc)
.pipe(plumber({
errorHandler : notify.onError({
title : 'error in <%= error.plugin %>',
message : '<%= error.message %>'
})
}) )
.pipe(sourcemaps.init() )
.pipe(order([ '**/*.ts' ]) )
.pipe(mainTsProject() )
.pipe(sourcemaps.write('.') )
.pipe(gulp.dest(build) );
});
gulp.task('concat-main-css', function() {
return gulp.src(mainCssSrc)
.pipe(order([ '**/*.css' ]) )
.pipe(concat(`${targetName}.css`) )
.pipe(gulp.dest(`${build}/`) );
});
gulp.task('compress-main', gulp.series('build-main', function() {
return gulp.src(`${build}/${targetName}.js`)
.pipe(uglify({ output : { ascii_only : true } }) )
.pipe(rename({ suffix: '.min' }) )
.pipe(gulp.dest(`${build}/`) );
}) );
gulp.task('build', gulp.series('compress-main', 'concat-main-css') );
gulp.task('watch', function() {
var src = mainTsSrc.concat(mainCssSrc);
gulp.watch(src, gulp.series('build') )
.on('change', function(path) {
console.log(path);
});
});
gulp.task('default', gulp.series('clean', 'build') );