-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (55 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
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
clean = require('gulp-clean'),
watch = require('gulp-watch'),
autoprefixer = require('gulp-autoprefixer'),
less = require('gulp-less'),
browserify = require('gulp-browserify'),
connect = require('gulp-connect'),
qunit = require('gulp-qunit');
gulp.task('styles', function() {
return gulp.src(['src/assets/styles/normalize.css', 'src/assets/styles/style.less'])
.pipe(less())
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(concat('style.min.css'))
.pipe(gulp.dest('dist/assets/styles/'));
});
gulp.task('scripts', function() {
return gulp.src('src/assets/images/**/*')
.pipe(browserify({insertGlobals : true}))
.pipe(uglify())
.pipe(gulp.dest('dist/assets/images'));
});
gulp.task('images', function() {
return gulp.src('src/assets/images/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('dist/assets/images'));
});
gulp.task('clean', function() {
return gulp.src(['dist/assets/styles', 'dist/assets/scripts', 'dist/assets/graphics'], {read: false})
.pipe(clean());
});
gulp.task('copy', function() {
return gulp.src(['src/index.html', 'src/humans.txt', 'src/robots.txt', 'src/favicon.ico', 'src/crossdomain.xml', 'src/apple-touch-icon-precomposed.png'])
.pipe(gulp.dest('dist/'));
});
gulp.task('copy-lib', function() {
return gulp.src(['src/assets/libraries/**/*'])
.pipe(gulp.dest('dist/assets/libraries/'));
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'images', 'copy-lib', 'copy');
});
gulp.task('connect', connect.server({
root: ['dist'],
}));
gulp.task('watch', function() {
gulp.watch('src/assets/styles/**/*.less', ['styles']);
gulp.watch('src/assets/images/**/*', ['images']);
gulp.watch('src/assets/scripts/**/*', ['scripts']);
gulp.watch('src/assets/libraries/**/*', ['copy-lib']);
gulp.watch('src/*', ['copy']);
});
gulp.task('dev', ['connect', 'watch']);