-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
57 lines (50 loc) · 1.68 KB
/
gulpfile.ts
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
import { task } from 'gulp';
const path = require('path');
import * as gulp from 'gulp';
const gulpClean = require('gulp-clean');
const embedTemplates = require('gulp-angular-embed-templates');
const embedSass = require('gulp-angular2-embed-sass');
const resolveBin = require('resolve-bin');
import * as child_process from 'child_process';
import gulpRunSequence = require('run-sequence');
const exec = require('child_process').exec;
const DIST_ROOT = path.join(__dirname, 'dist');
const STAGE_ROOT = path.join(__dirname, 'staging');
const SRC_ROOT = path.join(__dirname, 'src');
const tsConfigPath = path.join(__dirname, 'tsconfig.prod.json');
task(':ts:stage', function () {
return gulp.src(path.join(SRC_ROOT, '**/*.ts')) // also can use *.js files
.pipe(embedTemplates({ sourceType: 'ts' }))
.pipe(embedSass({}))
.pipe(gulp.dest(STAGE_ROOT));
});
task('clean', [':clean:dist', ':clean:stage']);
task('dist', (done) => {
gulpRunSequence(
'clean',
':ts:stage',
':ts:build',
':copy-sass',
done
);
});
task(':clean:dist', cleanTask(DIST_ROOT));
task(':clean:stage', cleanTask(STAGE_ROOT));
task(':ts:build', function () {
exec(`tsc -p "${tsConfigPath}"`, (err, stdout, stderr) => {
console.log('dist done!');
});
});
task(':copy-sass', ()=>{
return gulp.src(path.join(SRC_ROOT, '**/*.scss'))
.pipe(gulp.dest(DIST_ROOT));
});
task('publish', function(){
exec(`npm publish --registry https://registry.npmjs.org/`, () => {
console.log('publish done');
});
});
/** Delete files. */
export function cleanTask(glob: string) {
return () => gulp.src(glob, { read: false }).pipe(gulpClean(null));
}