-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
68 lines (49 loc) · 1.57 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
"use strict";
var t = new Date().getTime()
var js_all = 'js/all.min.js';
var js_vendor = 'js/vendor.min.js';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
build = require('gulp-build'),
minifyCSS = require('gulp-minify-css'),
sourcemaps = require('gulp-sourcemaps'),
clean = require('gulp-clean'),
htmlreplace = require('gulp-html-replace'),
stylish = require('jshint-stylish');
gulp.task('clean_all', function () {
gulp.src('build/*')
.pipe(clean({force: true}));
});
gulp.task('copy', function () {
gulp.src('**/*.html', { cwd: 'app' })
.pipe(htmlreplace({
js:[js_vendor+'?'+t, js_all+'?'+t],
css: ['css/all.min.css?'+t]
}))
.pipe(gulp.dest('build'));
gulp.src('data/**/*', { cwd: 'app' })
.pipe(gulp.dest('build/data'));
});
gulp.task('minify-css', function () {
gulp.src(['css/reset.css', 'bower_components/c3/c3.min.css', 'css/styles.css'], { cwd: 'app' })
.pipe(minifyCSS())
.pipe(concat('all.min.css'))
.pipe(gulp.dest('build/css'));
});
gulp.task('js', function () {
gulp.src('js/*.js', { cwd: 'app' })
.pipe(jshint())
// .pipe(jshint.reporter('default'))
.pipe(jshint.reporter(stylish))
.pipe(uglify())
.pipe(concat(js_all))
.pipe(gulp.dest('build'));
gulp.src('bower_components/**/*.min.js', { cwd: 'app' })
.pipe(uglify())
.pipe(concat(js_vendor))
.pipe(gulp.dest('build'));
});
gulp.task('default', ['copy', 'js', 'minify-css']);
gulp.task('build', ['js', 'minify-css']);