-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
78 lines (62 loc) · 1.98 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
'use strict';
const gulp = require('gulp');
const ts = require('gulp-typescript');
const sass = require('gulp-sass');
const concat = require('gulp-concat');
const concatCss = require('gulp-concat-css');
const uglify = require('gulp-uglify');
const uglifyCss = require('gulp-uglifycss');
const jasmine = require('gulp-jasmine');
function throwPluginError(err) {
console.error('ERROR:\nplugin %s has thrown an error: %s', err.plugin, err.message);
return process.exit(1);
}
function compileTs() {
const tsProject = ts.createProject('tsconfig.json');
return tsProject
.src()
.pipe(ts(tsProject))
.js.pipe(gulp.dest('./compiled'));
}
function compileSass() {
return gulp.src('./src/**/*.scss')
.pipe(sass()
.on('error', throwPluginError))
.pipe(gulp.dest('./compiled/src/'));
}
function minJs() {
return gulp.src('./compiled/src/**/*.js')
.pipe(concat('SVGArcSpinner.min.js')
.on('error', throwPluginError))
.pipe(uglify()
.on('error', throwPluginError))
.pipe(gulp.dest('./dist/'));
}
function minCss() {
return gulp.src('./compiled/**/*.css')
.pipe(concatCss('SVGArcSpinner.min.css')
.on('error', throwPluginError))
.pipe(uglifyCss()
.on('error', throwPluginError))
.pipe(gulp.dest('./dist/'));
}
function declareTs() {
return gulp.src('./src/**/*.ts')
.pipe(ts({
declaration: true
})).dts.pipe(gulp.dest('./dist/'));
}
function test() {
return gulp.src('./compiled/spec/**/*.spec.js')
.pipe(jasmine()
.on('error', throwPluginError))
}
gulp
.task('compile-ts', compileTs)
.task('compile-sass', compileSass)
.task('build-js', ['compile-ts'], minJs)
.task('build-css', ['compile-sass'], minCss)
.task('declare-ts', declareTs)
.task('test', ['compile-ts'], test)
.task('build', ['build-js', 'build-css', 'declare-ts'])
.task('default', ['build']);