-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
46 lines (40 loc) · 1.21 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
/**
* Created by laixiangran on 2017/5/7.
* homepage:http://www.laixiangran.cn
*/
var gulp = require('gulp');
var os = require('os');
var path = require('path');
var sass = require('gulp-sass');
var rename = require("gulp-rename");
var inlineNg2Template = require('gulp-inline-ng2-template');
var runSequence = require('run-sequence').use(gulp);
var del = require('del');
var gulpif = require('gulp-if');
var clean = require('gulp-clean');
var config = {
src: './src',
dest: './dist',
aot: './aot'
};
gulp.task('clean:dist', function () {
return del.sync(config.dest, config.aot);
});
gulp.task('copy:src', ['clean:dist'], function () {
return gulp.src([config.src + '/**/*.*'])
.pipe(gulpif(/.+\.scss/g, sass({outputStyle: 'compressed'}).on('error', sass.logError)))
.pipe(rename(function (path) {
if (path.extname === '.css') {
path.extname = '.scss';
}
}))
.pipe(gulp.dest(config.aot));
});
gulp.task('ng2:inline', ['copy:src'], function () {
return gulp.src([config.aot + '/**/*.ts'])
.pipe(inlineNg2Template({useRelativePaths: true, target: 'es5'}))
.pipe(gulp.dest(config.aot + '/'));
});
gulp.task('prepublish', function (cb) {
runSequence(['clean:dist', 'copy:src', 'ng2:inline'], cb);
});