-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
84 lines (73 loc) · 2.25 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-cssnano');
var autoprefixer = require('gulp-autoprefixer');
var minifyHTML = require('gulp-htmlmin');
var concat = require('gulp-concat');
var del = require('del');
var webpack = require('webpack-stream');
var htmlReplace = require('gulp-html-replace');
gulp.task('clean', function() {
del.sync(['dist/css/**']);
del.sync(['dist/index.html']);
return del.sync(['dist/app/**']);
});
gulp.task('webpack', ['clean'], function() {
return gulp.src('src/app/app.ts')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('src/'));
});
gulp.task('js', ['webpack'], function() {
return gulp.src('src/bundle.js')
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('css', function() {
return gulp.src('src/**/*.css')
.pipe(autoprefixer())
.pipe(minifyCSS())
.pipe(gulp.dest('dist/'));
});
gulp.task('templates' , function(){
return gulp.src('src/app/*.html')
.pipe(gulp.dest('dist/app/'));
})
gulp.task('html', ['templates'], function() {
return gulp.src('src/index.html')
.pipe(htmlReplace({
'css': {
src: 'main.css',
tpl: '<link rel="stylesheet" type="text/css" href="%s">'
},
'js': ['dependencies.js', 'bundle.js']
}))
.pipe(minifyHTML())
.pipe(gulp.dest('dist/'));
});
gulp.task('assets', function() {
return gulp.src('src/**/*.png')
.pipe(gulp.dest('dist/'));
});
gulp.task('favicon', function() {
return gulp.src('src/favicon.ico')
.pipe(gulp.dest('dist/'));
});
gulp.task('dependencies', function() {
return gulp.src([//'node_modules/reflect-metadata/Reflect.js',
//'node_modules/zone.js/dist/zone.js',
// 'node_modules/angular2/bundles/angular2-polyfills.js',
// 'node_modules/systemjs/dist/system.js',
// 'node_modules/rxjs/bundles/Rx.js',
// 'node_modules/angular2/bundles/angular2.dev.js',
// 'node_modules/angular2/bundles/http.dev.js'
])
.pipe(concat('dependencies.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/'));
});
gulp.task('build', ['js', 'css', 'html', 'assets', 'favicon', 'dependencies'], function() {
// add git push heroku master;heroku ps:scale web=1
return del.sync(['src/bundle.js'])
});