-
Notifications
You must be signed in to change notification settings - Fork 82
/
gulpfile.js
83 lines (67 loc) · 2.69 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
var gulp = require('gulp');
var del = require('del');
var tsc = require('gulp-typescript');
var gulpTypings = require("gulp-typings");
var sourcemaps = require('gulp-sourcemaps');
var tscConfig = require('./tsconfig.json');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var inlineNg2Template = require('gulp-inline-ng2-template');
var runSequence = require('run-sequence');
gulp.task('clean', function () {
return del.sync('lib/**/*');
});
gulp.task("typings", function () {
return gulp.src("./typings.json").pipe(gulpTypings());
});
gulp.task('sass', function () {
return gulp.src('src/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('src'));
});
gulp.task('createts', function () {
return gulp.src(['src/**/*.ts'])
.pipe(inlineNg2Template({base: '/src'}))
.pipe(gulp.dest('lib'));
});
gulp.task('compile:lib', function () {
var r = gulp.src(['typings/index.d.ts', 'lib/**/*.ts'])
.pipe(sourcemaps.init())
.pipe(tsc(tscConfig.compilerOptions));
r.dts.pipe(gulp.dest('lib'));
r.js.pipe(uglify()).pipe(gulp.dest('lib'));
return r.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'));
});
gulp.task('compile:index', function () {
var r = gulp.src(['typings/index.d.ts', 'index.ts'])
.pipe(sourcemaps.init())
.pipe(tsc(tscConfig.compilerOptions));
r.dts.pipe(gulp.dest('.'));
r.js.pipe(gulp.dest('.'));
return r.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.'));
});
gulp.task('clean:postcompile', function () {
return del.sync('src/templates/default/color-picker.css');
});
gulp.task('default', function (callback) {
runSequence('clean', 'typings', 'sass', 'createts', 'compile:lib', 'compile:index', 'clean:postcompile', callback);
});
//copy the library to example/node_modules/angular2-color-picker and examples_webpack/node_modules/angular2-color-picker
gulp.task('copylib', function (callback) {
runSequence('clean:examples', 'copy:lib', 'copy:index', callback);
});
gulp.task('copy:lib', function () {
return gulp.src(['lib/**/*'])
.pipe(gulp.dest('examples_webpack/node_modules/angular2-color-picker/lib'))
.pipe(gulp.dest('examples/node_modules/angular2-color-picker/lib'));
});
gulp.task('copy:index', function () {
return gulp.src(['index.*'])
.pipe(gulp.dest('examples/node_modules/angular2-color-picker'))
.pipe(gulp.dest('examples/node_modules/angular2-color-picker'));
});
gulp.task('clean:examples', function () {
return del.sync('examples_webpack/node_modules/angular2-color-picker/**/*', 'examples/node_modules/angular2-color-picker/**/*');
});