-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (72 loc) · 2.2 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var optimzeJs = require('gulp-optimize-js');
var concatCss = require('gulp-concat-css');
var cleanCSS = require('gulp-clean-css');
var htmlmin = require('gulp-htmlmin');
var watch = require('gulp-watch');
var scripts = [
'./js/lib/jquery-2.1.4.min.js',
'./js/lib/bootstrap.min.js',
'./js/lib/jrss.js',
'./js/lib/jfeed.js',
'./js/lib/jfeeditem.js',
'./js/lib/jquery.simpleWeather.min.js',
'./js/*'
];
var cssFiles = [
'./css/*'
];
var htmlFiles = [
'index.html'
];
gulp.task('uglyScripts', function() {
return gulp.src(scripts)
.pipe(concat('all.js'))
.pipe(gulp.dest('./dist/'))
.pipe(rename('all.min.js'))
.pipe(uglify())
.pipe(optimzeJs())
.pipe(gulp.dest('./dist/'));
});
gulp.task('uglyCSSFiles', function () {
return gulp.src(cssFiles)
.pipe(concatCss("all.css"))
.pipe(gulp.dest('./dist/'))
.pipe(rename('all.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('uglyHTML', function() {
return gulp.src(htmlFiles)
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(rename('index.min.html'))
.pipe(gulp.dest('./dist'));
});
gulp.task('scripts', function() {
return gulp.src(scripts)
.pipe(concat('all.js'))
.pipe(gulp.dest('./dist/'))
.pipe(rename('all.min.js'))
.pipe(gulp.dest('./dist/'));
});
gulp.task('cssFiles', function () {
return gulp.src(cssFiles)
.pipe(concatCss("all.css"))
.pipe(gulp.dest('./dist/'))
.pipe(rename('all.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('html', function() {
return gulp.src(htmlFiles)
.pipe(rename('index.min.html'))
.pipe(gulp.dest('./dist'));
});
gulp.task('watch', ['scripts', 'cssFiles', 'html'], function() {
gulp.watch(scripts.concat(cssFiles).concat(htmlFiles), ['dev'])
});
gulp.task('dev', ['html', 'cssFiles', 'scripts']);
gulp.task('default', ['uglyScripts', 'uglyCSSFiles', 'uglyHTML']);