-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (52 loc) · 1.52 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
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var watch = require('gulp-watch');
var minifyCss = require('gulp-minify-css');
var less = require('gulp-less');
var LessPluginAutoPrefix = require('less-plugin-autoprefix');
var autoprefix = new LessPluginAutoPrefix({ browsers: ['last 2 versions'] });
var minifyHtml = require('gulp-minify-html');
var livereload = require('gulp-livereload');
var server = require('gulp-webserver');
gulp.task('default', ['css', 'js', 'html']);
gulp.task('dev', ['watch']);
gulp.task('watch', function() {
gulp.src('dist')
.pipe(server({
livereload: true,
open: true
}));
gulp.src('src/css/*.less')
.pipe(watch('src/css/*.less', function() {
gulp.start('css');
}, { verbose: true }));
gulp.src('src/js/*.js')
.pipe(watch('src/js/*.js', function() {
gulp.start('js');
}, { verbose: true }));
gulp.src('src/*.html')
.pipe(watch('src/*.html', function() {
gulp.start('html');
}, { verbose: true }));
});
gulp.task('css', function() {
return gulp.src('src/css/*.less')
.pipe(less({ plugins: [autoprefix] }))
.on('error', gutil.log)
.pipe(minifyCss())
.pipe(gulp.dest('dist/css'))
.on('error', gutil.log)
.pipe(livereload());
});
gulp.task('js', function() {
return gulp.src('src/js/*.js')
.pipe(gulp.dest('dist/js'))
.pipe(livereload());
});
gulp.task('html', function() {
return gulp.src('src/*.html')
.pipe(minifyHtml())
.pipe(gulp.dest('dist'))
.pipe(livereload());
});