-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
80 lines (70 loc) · 2.1 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
var gulp = require('gulp'),
watch = require('gulp-watch'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
browserify = require("browserify"),
vinylSourceStream = require('vinyl-source-stream'),
vinylBuffer = require('vinyl-buffer'),
to5Browserify = require("6to5-browserify"),
karma = require('karma').server;
var srcAppJs = './front/src/**/*.js';
gulp.task('js:lint', function() {
return gulp.src(srcAppJs)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
function jsBuild(dest) {
var bundler = browserify({
entries: ['./front/src/app.js'],
debug: true
});
return bundler
.transform(to5Browserify)
.bundle()
.on("error", function (err) { console.log("Error : " + err.message); })
.pipe(vinylSourceStream("app.js"))
.pipe(vinylBuffer())
.pipe(gulp.dest(dest));
}
gulp.task('js:build', function() {
return jsBuild('public/javascripts/')
});
gulp.task('js:test', function (done) {
jsBuild('front/test/build/');
karma.start({
configFile: __dirname + '/front/test/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('assets:js', function() {
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/angularjs/angular.min.js'
])
.pipe(concat('assets.js'))
.pipe(uglify())
.pipe(gulp.dest('public/javascripts/'));
});
gulp.task('assets:css', function() {
return gulp.src([
'bower_components/bootstrap/dist/css/bootstrap.min.css'
])
.pipe(concat('assets.css'))
.pipe(gulp.dest('public/stylesheets/'));
});
gulp.task('assets:fonts', function() {
return gulp.src([
'bower_components/bootstrap/dist/fonts/**/*'
])
.pipe(gulp.dest('public/fonts/'));
});
gulp.task('js', ['js:lint', 'js:build']);
gulp.task('build', ['assets:js', 'assets:css', 'assets:fonts', 'js']);
gulp.task('test', ['js:test']);
gulp.task('watch', function() {
watching = true;
gulp.watch(srcAppJs, ['js']);
});
gulp.task('default', ['build', 'watch']);