-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
82 lines (70 loc) · 1.92 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
var gulp = require('gulp'),
less = require('gulp-less'),
usemin = require('gulp-usemin'),
wrap = require('gulp-wrap'),
connect = require('gulp-connect'),
watch = require('gulp-watch');
var paths = {
js: 'src/js/**/*.*',
fonts: 'src/fonts/**.*',
images: 'src/img/**/*.*',
styles: 'src/less/**/*.less',
index: 'src/index.html',
bower_fonts: 'src/bower_components/**/*.{ttf,woff,eof,svg}',
bower_components: 'src/bower_components/**/*.*',
watch_path: 'src/less/dashboard/**/*.less'
};
gulp.task('usemin', function() {
return gulp.src(paths.index)
.pipe(usemin({
less: [less(), 'concat'],
js: ['concat', wrap('(function(){ \n<%= contents %>\n})();')],
}))
.pipe(gulp.dest('dist/'));
});
/**
* Copy assets
*/
gulp.task('copy-assets', ['copy-images', 'copy-fonts', 'copy-bower_fonts']);
gulp.task('copy-images', function(){
return gulp.src(paths.images)
.pipe(gulp.dest('dist/img'));
});
gulp.task('copy-fonts', function(){
return gulp.src(paths.fonts)
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('copy-bower_fonts', function(){
return gulp.src(paths.bower_fonts)
.pipe(gulp.dest('dist/lib'));
});
/**
* Watch src
*/
gulp.task('watch', function () {
gulp.watch([paths.styles, paths.index, paths.js], ['usemin']);
gulp.watch([paths.images], ['copy-images']);
gulp.watch([paths.fonts], ['copy-fonts']);
gulp.watch([paths.bower_fonts], ['copy-bower_fonts']);
});
gulp.task('webserver', function() {
connect.server({
root: 'dist',
livereload: true
});
});
gulp.task('livereload', function() {
gulp.src(['dist/**/*.*'])
.pipe(watch())
.pipe(connect.reload());
});
/**
* Compile less
*/
gulp.task('compile-less', function(){
return gulp.src(paths.styles)
.pipe(less())
.pipe(gulp.dest('dist/css'));
});
gulp.task('build', ['usemin', 'copy-assets']);
gulp.task('default', ['build', 'webserver', 'livereload', 'watch']);