-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
67 lines (62 loc) · 1.65 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
var gulp = require("gulp");
var htmlclean = require("gulp-htmlclean");
var imagemin = require('gulp-imagemin');
var uglifyjs = require('gulp-uglify');
var stripdebug = require("gulp-strip-debug");
var concat = require("gulp-concat");
var less = require("gulp-less");
var postcss = require("gulp-postcss");
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var connect = require('gulp-connect');
var devMode = process.env.NODE_ENV=="development";
var folder = {
src:'src/',
dist:'dist/'
}
console.log(devMode)
gulp.task("html",function(){
var page = gulp.src(folder.src+"html/*")
.pipe(connect.reload())
if(!devMode){
page.pipe(htmlclean())
}
page.pipe(gulp.dest(folder.dist+"html/"))
})
gulp.task('images',function(){
gulp.src(folder.src+"images/*")
.pipe(imagemin())
.pipe(gulp.dest(folder.dist+"images/"))
})
gulp.task('js',function(){
var page = gulp.src(folder.src + "js/*")
.pipe(connect.reload())
if(!devMode){
page.pipe(stripdebug())
.pipe(uglifyjs())
}
page.pipe(gulp.dest(folder.dist+"js/"))
})
gulp.task("css",function(){
var options = [autoprefixer(),cssnano()];
var page = gulp.src(folder.src+'css/*')
.pipe(connect.reload())
.pipe(less())
if(!devMode){
page.pipe(postcss(options))
}
page.pipe(gulp.dest(folder.dist+"css/"))
})
gulp.task('watch',function(){
gulp.watch(folder.src+'html/*',['html']);
gulp.watch(folder.src+'css/*',['css']);
gulp.watch(folder.src+'js/*',['js']);
gulp.watch(folder.src+'images/*',['images']);
})
gulp.task('server',function(){
connect.server({
port:'8090',
liveload:true
});
})
gulp.task('default',['html','images','js','css','watch','server'])