-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (77 loc) · 1.96 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
var gulp = require('gulp'),
runSequence = require('run-sequence'),
concat = require('gulp-concat'),
minHTML = require('gulp-minify-html'),
minCSS = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
del = require('del'),
connect = require('gulp-connect'),
usemin = require('gulp-usemin'),
imagemin = require('gulp-imagemin');
var config = {
htmlMain: [
'app/index.html'
],
html: [
'app/pages/**/*.html'
],
css:[
'app/css/**/*.css'
],
img: [
'app/img/**/*.{png,jpg,jpeg,gif,svg}'
],
scripts:[
'app/js/**/*.js'
]
};
gulp.task('default', ['public', 'webserver', 'watch']);
gulp.task('public', function(callback) {
runSequence('del',
['html', 'img', 'usemin'],
callback);
});
gulp.task('webserver', function() {
connect.server({
root: 'dist',
livereload: true,
port: 8888
});
});
gulp.task('watch', function(){
gulp.watch(config.htmlMain, ['usemin']);
gulp.watch(config.html, ['html']);
gulp.watch(config.css, ['usemin']);
gulp.watch(config.scripts, ['usemin']);
gulp.watch(config.img, ['img']);
});
gulp.task('del', function () {
return del('dist/');
});
gulp.task('html-index', function(){
gulp.src(config.htmlMain)
//.pipe(minHTML())
.pipe(gulp.dest('dist/'));
});
gulp.task('html', function(){
gulp.src(config.html)
.pipe(minHTML())
.pipe(gulp.dest('dist/pages/'))
.pipe(connect.reload());
});
gulp.task('img', function(){
gulp.src(config.img)
.pipe(imagemin())
.pipe(gulp.dest('dist/img'))
.pipe(connect.reload());
});
gulp.task('usemin', ['html-index'], function() {
return gulp.src(config.htmlMain)
.pipe(usemin({
css: [minCSS(), 'concat'],
js: ['concat'],
js1: [uglify({mangle: false}), 'concat']
}))
.pipe(gulp.dest('dist/'))
.pipe(connect.reload());
});