forked from fluffywaffles/3D-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
86 lines (72 loc) · 2.17 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
var gulp = require('gulp')
, del = require('del')
, browserSync = require('browser-sync')
// load plugins
var $ = require('gulp-load-plugins')();
gulp.task('styles', function () {
return gulp.src('app/styles/main.styl')
.pipe($.sourcemaps.init())
.pipe($.stylus())
.pipe($.autoprefixer('last 4 versions'))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('dist'))
.pipe($.size())
.pipe(browserSync.stream())
});
gulp.task('jade', function () {
return gulp.src(['app/jade/**/*.jade'])
.pipe($.pug({pretty: true}))
.pipe($.useref())
.pipe(gulp.dest('.tmp'))
.pipe($.size())
});
gulp.task('scripts', function () {
return gulp.src('app/scripts/**/*.js')
.pipe($.sourcemaps.init())
.pipe($.uglify())
.pipe($.sourcemaps.write())
.pipe($.size())
.pipe(gulp.dest('dist'));
});
gulp.task('images', function () {
return gulp.src('app/images/**/*')
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe(gulp.dest('dist/images'))
.pipe($.size());
});
gulp.task('extras', function () {
return gulp.src('app/*.*', { dot: true })
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function () {
return del(['app/**/*.html', 'dist'])
});
gulp.task('build', ['jade', 'images', 'extras']);
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
gulp.task('serve', ['jade', 'styles', 'scripts', 'images'], function () {
browserSync.init({
server: {
baseDir: [ './dist', './.tmp' ]
}
})
});
gulp.task('watch', ['serve'], function () {
// watch for changes
gulp.watch([
'app/scripts/**/*.js',
'app/images/**/*',
'app/jade/**/*.jade'
])
gulp.watch('app/styles/**/*.styl', ['styles']);
gulp.watch('app/scripts/**/*.js', ['scripts']);
gulp.watch('app/images/**/*', ['images']);
gulp.watch('app/jade/**/*.jade', ['jade']);
gulp.watch('app/*.html').on('change', browserSync.reload)
gulp.watch('dist/**/*.js').on('change', browserSync.reload)
});