forked from michaelbromley/angular-es6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (50 loc) · 1.65 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
var gulp = require('gulp');
var inject = require('gulp-inject');
var to5 = require('gulp-6to5');
var annotate = require('gulp-ng-annotate');
var less = require('gulp-less');
var ts = require('gulp-typescript');
var es = require('event-stream');
gulp.task('scripts', function () {
var javascripts = gulp.src('./src/**/*.js')
.pipe(to5());
var typescripts = gulp.src('./src/**/*.ts')
.pipe(ts({
target: 'ES5'
}));
es.merge(typescripts.js, javascripts)
.pipe(annotate())
.pipe(gulp.dest('./build'));
});
gulp.task('styles', function() {
return gulp.src('./src/**/*.less')
.pipe(less())
.pipe(gulp.dest('./build'));
});
gulp.task('templates', function() {
return gulp.src('./src/**/*.tpl.html')
.pipe(gulp.dest('./build'));
});
gulp.task('index', ['scripts', 'styles', 'templates'], function() {
var target = gulp.src('./src/index.html');
var js = gulp.src([
'../bower_components/angular/angular.js',
'app/utils/register.js',
'app/app.js',
'**/!(app.js)'
], {read: false, cwd: './build/'});
var css = gulp.src([
'styles/main.css'
], {read: false, cwd: './build/'});
target
.pipe(inject(js, { addRootSlash: false }))
.pipe(inject(css, { addRootSlash: false }))
.pipe(gulp.dest('./build'));
});
gulp.task('watch', ['index'], function () {
gulp.watch(['./src/**/*.js', './src/**/*.ts'], ['scripts']);
gulp.watch('./src/**/*.less', ['styles']);
gulp.watch('./src/**/*.tpl.html', ['templates']);
gulp.watch('./src/index.html', ['index']);
});
gulp.task('default', ['index']);