-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
107 lines (91 loc) · 2.77 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* TODO:
* - rjs not running after lint fails, then fixed syntax error
* - get sourcemaps when supported
*/
var gulp = require('gulp'),
bump = require('gulp-bump'),
del = require('del'),
rename = require('gulp-rename'),
stylus = require('gulp-stylus'),
nib = require('nib'),
jshint = require('gulp-jshint'),
to5 = require('gulp-6to5'),
rjs = require('gulp-requirejs'),
uglify = require('gulp-uglify'),
livereload = require('gulp-livereload');
gulp.task('css', function(){
return gulp.src('public/css/style.styl')
.pipe(stylus({use: [nib()], import: ['nib']}))
.pipe(gulp.dest('public/css'));
});
gulp.task('js', function() {
return gulp.src(['./public/js/src/**/*.js', '!./public/js/src/bower_components/**'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(gulp.src(rjs({
out: 'eggshell.js',
baseUrl: './public/js/src',
mainConfigFile: './public/js/src/config.js',
name: 'config',
optimize: 'none',
include: 'require-lib',
useSourceUrl: true
}).pipe(gulp.dest('./public/js/dist/dev/')))
)
//.pipe(gulp.dest('./public/js/dist/dev/'))
//.pipe(uglify())
//.pipe(gulp.dest('./public/js/dist/prod/'));
});
gulp.task('rjs', ['6to5', 'lint'], function(){
return rjs({
out: 'eggshell.js',
baseUrl: './public/js/src',
mainConfigFile: './public/js/src/config.js',
name: 'config',
optimize: 'none',
include: 'require-lib',
useSourceUrl: true
})
.pipe(gulp.dest('./public/js/dist/dev/'))
.pipe(uglify())
.pipe(gulp.dest('./public/js/dist/prod/'));
});
gulp.task('lint', function() {
return gulp.src(['./public/js/src/**/*.js', '!./public/js/src/bower_components/**'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('6to5', function () {
return gulp.src('./public/js/src/**/*.es6')
.pipe(to5())
.pipe(rename({extname: '.js'}))
.pipe(gulp.dest('./public/js/src'));
});
gulp.task('clean', function(cb) {
del([
'./public/js/dist/**'
], cb);
});
// Increment packages by patch point
gulp.task('bump', function(){
return gulp.src(['./bower.json', './package.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
});
gulp.task('watch', function(){
gulp.watch('./public/css/style.styl', ['css']);
gulp.watch(['./public/js/src/**/*.js','public/js/src/views/**/*.mustache'], ['js']);
var server = livereload();
gulp.watch([
'./public/js/dist/**/*.js',
'./public/js/test/*.js',
'./public/css/*.css'
]).on('change', function(file) {
//console.log(file.path + ' changed')
server.changed(file.path);
});
});
gulp.task('default', ['clean', 'css', 'lint', 'rjs']);
gulp.task('build', ['clean', 'css', 'rjs', 'bump']);