forked from dcfvg/facture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
67 lines (56 loc) · 1.95 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
const gulp = require('gulp'),
less = require('gulp-less'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var browserSync = require('browser-sync').create();
gulp.task('less', function() {
return gulp.src('./assets/less/*.less')
.pipe(less())
.pipe(gulp.dest('./assets/css'));
});
gulp.task('build-js', function() {
return gulp.src([
'./bower_components/jquery/dist/jquery.js',
'./bower_components/lodash/lodash.js',
'./bower_components/handlebars/handlebars.min.js',
'./bower_components/d3/d3.min.js',
'./bower_components/papaparse/papaparse.min.js',
'./bower_components/moment/min/moment.min.js',
'./bower_components/file-saver/FileSaver.min.js',
],
{base: 'bower_components/'}
)
.pipe(concat('libs.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./assets/js/'));
});
gulp.task('watch', function() {
});
gulp.task('serve', function() {
browserSync.init({ server: "./" });
gulp.watch('./assets/less/*.less', ['less']);
gulp.watch('./templates/*.hbs', ['templates']);
gulp.watch("./assets/less/*.less").on('change', browserSync.reload);
gulp.watch("./templates/*.hbs").on('change', browserSync.reload);
gulp.watch("./*.html").on('change', browserSync.reload);
});
// copy fonts
gulp.task('fonts', function() {
return gulp.src(['./bower_components/bootstrap/dist/fonts/*.*'])
.pipe(gulp.dest('./assets/fonts/'));
});
gulp.task('templates', function(){
gulp.src('./templates/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'fac',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest('assets/js/'));
});
gulp.task('default', [ 'build-js', 'less', 'watch', 'fonts']);