-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (61 loc) · 1.51 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
var gulp = require('gulp'),
ts = require('gulp-typescript'),
bs = require('browser-sync').create(),
plumber = require('gulp-plumber'),
jade = require('gulp-jade'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
path = require('path');
/**
* Compiles Sass files to css
*/
gulp.task('sass', function() {
gulp.src('src/sass/**/*.{sass, scss}')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'ff 17', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('dist/css'))
.pipe(bs.stream());
});
/**
* Compiles jade files to html
*/
gulp.task('templates', function() {
var locals = {};
gulp.src('*.jade')
.pipe(plumber())
.pipe(jade({
locals: locals,
pretty: true
}))
.pipe(gulp.dest('.'))
});
/**
* Browser Sync task
*/
gulp.task('bs', function() {
bs.init({
server: './'
});
gulp.watch('*.html', bs.reload);
gulp.watch('dist/js/*.js', bs.reload);
gulp.watch('dist/css/*.css', bs.reload);
});
gulp.task('build-ts', function() {
console.log('Building TS');
gulp.src('src/ts/*.ts')
.pipe(ts({
target: 'es5',
module: 'commonjs'
}))
.pipe(gulp.dest("dist/js"));
});
/**
* Watch task
*/
gulp.task('watch', ['bs'], function() {
gulp.watch('*.jade', ['templates']);
gulp.watch('src/jade/*.jade', ['templates'], function() {bs.reload();});
gulp.watch('src/sass/*.{sass, scss}', ['sass']);
gulp.watch('./src/ts/*.ts', ['build-ts']);
});
gulp.task('default', ['watch']);