forked from basvandenberg/ng-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (70 loc) · 2.44 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
"use strict";
var del = require('del');
var exec = require('child_process').exec;
var fs = require('fs');
var gulp = require('gulp');
var os = require('os');
var sass = require('gulp-sass');
var tslint = require('gulp-tslint');
gulp.task('default', ['build']);
// Build.
gulp.task('build', ['transpile:ts'], function() {
return del([
'./aot',
'./src/select.component.html.ts',
'./src/select.component.css',
'./src/select.component.css.ts',
'./src/select-dropdown.component.html.ts',
'./src/select-dropdown.component.css',
'./src/select-dropdown.component.css.ts'
]);
});
gulp.task('watch', function() {
gulp.watch(['./src/**/*'], ['build']);
});
gulp.task('clean', function() {
return del(['./aot', './dist/**/*']);
});
// Typescript --> Javascript.
gulp.task('lint:ts', function() {
return gulp.src(['./src/*.ts'])
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
});
gulp.task('transpile:ts', ['clean', 'templates', 'styles'], function (cb) {
var cmd = os.platform() === 'win32' ?
'node_modules\\.bin\\ngc -p src/tsconfig.json' :
'./node_modules/.bin/ngc -p src/tsconfig.json';
exec(cmd, function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
// HTML template --> Typescript.
gulp.task('templates', ['lint:ts'], function() {
var t1 = fs.readFileSync('./src/select.component.html', 'utf8');
var t2 = fs.readFileSync('./src/select-dropdown.component.html', 'utf8');
t1 = 'export const TEMPLATE = `' + t1 + '`;';
t2 = 'export const TEMPLATE = `' + t2 + '`;';
fs.writeFileSync('./src/select.component.html.ts', t1);
fs.writeFileSync('./src/select-dropdown.component.html.ts', t2);
return;
});
// Sass --> CSS -> Typescript.
gulp.task('styles', ['transpile:sass'], function() {
var s1 = fs.readFileSync('./src/select.component.css', 'utf8');
var s2 = fs.readFileSync('./src/select-dropdown.component.css', 'utf8');
s1 = 'export const STYLE = `' + s1 + '`;';
s2 = 'export const STYLE = `' + s2 + '`;';
fs.writeFileSync('./src/select.component.css.ts', s1);
fs.writeFileSync('./src/select-dropdown.component.css.ts', s2);
return;
});
gulp.task('transpile:sass', function() {
return gulp.src('./src/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./src/'))
});