-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
62 lines (54 loc) · 1.75 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
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
usemin = require('gulp-usemin'),
concat = require('gulp-concat'),
cache = require('gulp-cache'),
clean = require('gulp-clean'),
connect = require('connect'),
morgan = require('morgan'),
serveStatic = require('serve-static'),
deploy = require('gulp-gh-pages'),
http = require('http');
var config = {
port: 8082,
root: 'dist/'
};
gulp.task('build', ['images', 'jshint'], function() {
return gulp.src('src/*.html')
.pipe(usemin({
css: [autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'), minifycss(), 'concat'],
js: [uglify(), 'concat']
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('jshint', function() {
return gulp.src('src/scripts/**/*.js')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'));
});
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('dist/images'));
});
gulp.task('serve', function(){
var app = connect();
app.use(morgan('dev'));
app.use(serveStatic(config.root));
http.createServer(app).listen(config.port);
});
gulp.task('clean', function() {
return gulp.src(['dist/scripts', 'dist/styles', 'dist/**/*.html', 'dist/images'], {read: false})
.pipe(clean());
});
gulp.task('default', ['clean'], function () {
gulp.start('images', 'build', 'serve');
});
gulp.task('deploy', ['build'], function() {
gulp.src("./dist/**/*")
.pipe(deploy());
});