-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
98 lines (88 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var gulp = require('gulp'),
gutil = require('gulp-util'),
bower = require('bower'),
concat = require('gulp-concat'),
sass = require('gulp-sass'),
jade = require('gulp-jade'),
minifyCss = require('gulp-minify-css'),
rename = require('gulp-rename'),
sh = require('shelljs'),
plumber = require('gulp-plumber'),
uglify = require('gulp-uglify'),
ts = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps'),
paths = {
ts: ['./app/scripts/**/*.ts'],
sass: ['./app/assets/sass/**/!(app)*.scss', './app/assets/sass/app.scss'],
jade: ['./app/assets/views/**/*.jade'],
assets: ['./app/assets/assets/**/*']
};
gulp.task('default', ['sass', 'jade', 'ts', 'assets', 'watch']);
gulp.task('build', ['sass', 'jade', 'ts', 'assets']);
gulp.task('ts', function() {
var tsResult = gulp.src(paths.ts)
.pipe(sourcemaps.init())
.pipe(ts({
sortOutput: true,
target: 'ES5'
}));
return tsResult.js
.pipe(plumber())
.pipe(concat('app.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./public/build/js/'))
.pipe(uglify({mangle: true}))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('./public/build/js/'));
});
gulp.task('sass', function(done) {
gulp.src(paths.sass)
.pipe(plumber())
.pipe(sass())
.pipe(concat('app.css'))
.pipe(gulp.dest('./public/build/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./public/build/css/'))
.on('end', done);
});
gulp.task('jade', function (done) {
gulp.src(paths.jade)
.pipe(plumber())
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('./public/build/views/'))
.on('error', gutil.log)
.on('error', gutil.beep)
.on('end', done);
});
gulp.task('assets', function () {
gulp.src(paths.assets).pipe(gulp.dest('./public/build/assets'));
});
gulp.task('watch', ['sass', 'jade', 'ts'], function() {
gulp.watch(paths.sass, ['sass']);
gulp.watch(paths.jade, ['jade']);
gulp.watch(paths.assets, ['assets']);
gulp.watch(paths.ts, ['ts']);
});
gulp.task('install', ['git-check'], function() {
return bower.commands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function(done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
}
done();
});