-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
109 lines (97 loc) · 3.1 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var typescriptAngular = require('gulp-typescript-angular');
var concat = require('gulp-concat');
var order = require("gulp-order");
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var Server = require('karma').Server;
var clean = require('gulp-clean');
var p = require('./package.json');
var gulpCopy = require('gulp-copy');
var templateCache = require('gulp-angular-templatecache');
gulp.task('templates', function () {
return gulp.src('app/modules/**/*.html')
.pipe(templateCache({
module: 'app'
}))
.pipe(gulp.dest('public/tmp-scripts'));
});
gulp.task('copy-files', function() {
return gulp.src([
'bower_components/angular-toastr/dist/angular-toastr.min.css'
])
.pipe(gulpCopy('./public/', {}));
});
gulp.task('concat-bower', function() {
return gulp.src([
'bower_components/jquery/dist/jquery.js',
'bower_components/foundation/js/foundation.js',
'bower_components/foundation/js/foundation/foundation.topbar.js',
'bower_components/angular/angular.js',
'bower_components/angular-toastr/dist/angular-toastr.tpls.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-ui-router/release/angular-ui-router.js'
])
.pipe(order([
"jquery.js",
"foundation.js",
"angular.js"
]))
.pipe(concat('vendors.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/dist/'));
});
gulp.task('clean', function () {
return gulp.src('./public/tmp-scripts', {read: false})
.pipe(clean());
});
gulp.task('compile', ['templates', 'copy-files'], function () {
return gulp.src(
[
'./app/**/*.ts'
])
.pipe(typescript({
target:'es5',
experimentalDecorators: 'true'
}))
.pipe(typescriptAngular({
decoratorModuleName:'app'
}))
.pipe(gulp.dest('./public/tmp-scripts'));
});
gulp.task('unify-scripts', ['compile'], function() {
var bk = gulp.src('./public/tmp-scripts/**/*.js')
.pipe(concat(p.name + '_' + p.version + '.js'))
.pipe(uglify())
.pipe(gulp.dest('./public/dist'));
return bk;
});
gulp.task('sass', function () {
gulp.src('./resources/styles/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(concat(p.name + '_' + p.version + '.css'))
.pipe(gulp.dest('./public/dist'));
});
gulp.task('copy-icons', function () {
return gulp.src([
'./bower_components/foundation-icon-fonts/foundation-icons.ttf',
'./bower_components/foundation-icon-fonts/foundation-icons.woff'
]).pipe(gulp.dest('./public/dist'));
});
gulp.task('default', ['concat-bower', 'unify-scripts', 'sass', 'copy-icons', 'templates'], function() {
gulp.start('clean');
});
gulp.task('test', ['default'], function (done) {
new Server({
configFile: __dirname + '/tests/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('dev', ['concat-bower', 'unify-scripts', 'sass', 'copy-icons', 'templates'], function() {
gulp.start('clean');
gulp.watch('./app/**/*.ts', ['unify-scripts']);
gulp.watch('./app/modules/**/*.html', ['compile', 'unify-scripts']);
gulp.watch('./resources/styles/**/*.scss', ['sass']);
gulp.watch('./app/modules/**/*.scss', ['sass']);
});