-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
92 lines (79 loc) · 2.31 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
87
88
89
90
91
92
var gulp = require('gulp'),
sass = require('gulp-sass'),
less = require('gulp-less'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
cssnano = require('gulp-cssnano'),
rename = require('gulp-rename'),
del = require('del'),
imagemin = require('gulp-imagemin'),
pngquant = require('imagemin-pngquant');
autoprefixer= require('gulp-autoprefixer');
gulp.task('test',function () {
console.log("Gulp is working now");
});
gulp.task('sass',function () {
return gulp.src('app/sass/**/*.+(scss|sass)')
.pipe(sass())
.pipe(autoprefixer(['last 15 versions','> 1%', 'ie 8', 'ie 7'],{cascade: true}))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('less',function () {
return gulp.src('app/less/**/*.less')
.pipe(less())
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream:true}));
})
gulp.task('scripts',function () {
return gulp.src([
'app/libs/jquery/dist/jquery.min.js',
'app/libs/ajax/dist/ajax.min.js'])
.pipe(concat('libs.min.js'))
.pipe(uglify())
.pipe(gulp.dest('app/js'));
})
gulp.task('css-libs',function () {
return gulp.src('app/css/libs.css')
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('app/css'));
})
gulp.task('browser-sync',function () {
browserSync({
server:{
baseDir: 'app'
},
notify: false
});
});
gulp.task('img',function () {
gulp.src('app/img/**/*')
.pipe(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('build/img'));
})
gulp.task('watch',['browser-sync','sass','less'],function () {
gulp.watch('app/sass/**/*.+(scss|sass)',['sass']);
gulp.watch('app/*.html',browserSync.reload)
gulp.watch('app/js/**/*.js',browserSync.reload)
});
gulp.task('clear',function () {
return del.sync('build');
});
gulp.task('build',['clear','img','sass','less','scripts'],function () {
var builtCss= gulp.src('app/css/**/*.css')
.pipe(gulp.dest('build/css'));
var builtFonts = gulp.src('app/fonts/**/*')
.pipe(gulp.dest('build/fonts'));
var builtJS = gulp.src('app/js/**/*')
.pipe(gulp.dest('build/js'));
var builtHtml = gulp.src('app/*.html')
.pipe(gulp.dest('build'));
console.log("Mission Complete!");
});