-
Notifications
You must be signed in to change notification settings - Fork 265
/
gulpfile.js
57 lines (50 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
var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var del = require('del');
var cssnano = require('gulp-cssnano');
var autoprefixer = require('gulp-autoprefixer');
gulp.task('less', function() {
return gulp.src(['app/less/okayNav-base.less', 'app/less/okayNav-theme.less']) // Get source files with gulp.src
.pipe(less())
.pipe(autoprefixer('last 2 version', 'safari 5', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'app'
},
})
});
gulp.task('useref', ['less'], function(){
return gulp.src('app/*.html')
.pipe(useref())
.pipe(gulpIf('*.js', uglify({
preserveComments: 'license'
})))
.pipe(gulpIf('*.css', cssnano({autoprefixer: false})))
.pipe(gulp.dest('dist'))
});
gulp.task('clean:dist', function() {
return del.sync('dist');
});
gulp.task('watch', ['browserSync', 'less'], function(){
gulp.watch('app/less/**/*.less', ['less', browserSync.reload]);
gulp.watch('app/js/**/*.js', browserSync.reload);
gulp.watch('app/*.html', browserSync.reload);
});
gulp.task('build', ['clean:dist'], function (){
gulp.start('useref');
console.log('Building files');
});
// Default task
gulp.task('default', function() {
gulp.start('build');
});