-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
107 lines (89 loc) · 2.99 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
"use strict";
const gulp = require('gulp');
const del = require('del');
const ts = require('gulp-typescript');
const merge = require('merge2');
const connect = require('gulp-connect');
const tslint = require('tslint');
const gulpTslint = require('gulp-tslint');
const sm = require('gulp-sourcemaps');
const tsproj = ts.createProject('./tsconfig.json');
const exmapProj = ts.createProject('./tsconfig.json', { declaration: false });
gulp.task('compile:src', () => {
let tsResult = gulp.src(['components/**/*.ts', 'typings/**/*.ts'])
.pipe(sm.init())
.pipe(tsproj());
let css = gulp.src(['components/**/*.css']);
return merge([
tsResult.dts.pipe(gulp.dest('./out/')),
tsResult.js
.pipe(sm.write('.'))
.pipe(gulp.dest('./out/')),
css.pipe(gulp.dest('./out/'))
]);
});
gulp.task('compile:examples', (done) => {
let promises = [];
promises.push(new Promise((resolve) => {
gulp.src(['examples/**/*.ts', 'typings/**/*.ts', 'components/typings/**/*.ts'])
.pipe(exmapProj())
.pipe(gulp.dest('dist'))
.on('end', () => {
resolve();
});
}))
promises.push(new Promise((resolve) => {
gulp.src(['examples/**/*.html'])
.pipe(gulp.dest('dist'))
.on('end', () => {
resolve();
});
}))
promises.push(new Promise((resolve)=> {
gulp.src(['examples/**/*.js'])
.pipe(gulp.dest('dist'))
.on('end', () => {
resolve();
});
}));
promises.push(new Promise((resolve)=> {
gulp.src(['examples/**/*.css'])
.pipe(gulp.dest('dist'))
.on('end', () => {
resolve();
});
}));
Promise.all(promises).then(() => {
done();
});
});
gulp.task('compile', gulp.series('compile:src', 'compile:examples'));
gulp.task('lint:src', () => {
const program = tslint.Linter.createProgram('tsconfig.json');
return gulp.src(['components/**/*.ts', '!components/typings/**/*'])
.pipe((gulpTslint({
program,
formatter: "verbose",
rulesDirectory: "node_modules/tslint-microsoft-contrib"
})))
.pipe(gulpTslint.report());
});
gulp.task('lint:examples', () => {
const program = tslint.Linter.createProgram('tsconfig.json');
return gulp.src(['examples/**/*.ts'])
.pipe((gulpTslint({
program,
formatter: "verbose",
rulesDirectory: "node_modules/tslint-microsoft-contrib"
})))
.pipe(gulpTslint.report());
});
gulp.task('lint', gulp.series('lint:src', 'lint:examples'));
gulp.task('serve', () => {
connect.server();
});
gulp.task('clean', () => {
return del(['out', 'dist', 'index.js', 'index.d.ts'])
});
gulp.task('build', gulp.series('clean', 'lint', 'compile'));
gulp.task('publish', gulp.series('clean', 'lint', 'compile:src'));