forked from GoBoldlyForward/turntable
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
145 lines (128 loc) · 3.85 KB
/
gulpfile.js
File metadata and controls
145 lines (128 loc) · 3.85 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var babel = require('babelify');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var uglify = require('gulp-uglify');
var server = require('gulp-server-livereload');
var fontAwesome = require('node-font-awesome');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var htmlhint = require('gulp-htmlhint');
var jscs = require('gulp-jscs');
var watch = require('gulp-watch'); // A Better File Watcher
// Set up Foundation
var path = require('path');
var foundationEntry = require.resolve('foundation-sites');
var foundationSCSS = path.join(foundationEntry, '..', '..', '..', 'scss');
var notifyError = function() {
return plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
});
}
var browserifyError = function(err) {
notify.onError("Error: <%= error.message %>")(err);
this.emit('end');
}
gulp.task('sass', function () {
gulp.src('./sass/main.scss')
.pipe( notifyError() )
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sass({
includePaths: require('node-neat').with([fontAwesome.scssPath, foundationSCSS])
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./app/css'));
});
gulp.task('fonts', function() {
gulp.src(fontAwesome.fonts)
.pipe( notifyError() )
.pipe(gulp.dest('./app/fonts'));
});
gulp.task('normalize', function() {
gulp.src(require.resolve('normalize.css'))
.pipe( notifyError() )
.pipe(gulp.dest('./app/css'));
});
gulp.task('browserify', function() {
return browserify('./js/main.js', {debug: true})
.transform(babel)
.bundle()
.on('error', browserifyError)
.pipe(source('./main.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./app/js'));
});
// Janky - quick fix to write spec file
gulp.task('browserify-test', function() {
return browserify('./js/tests.js', {debug: true})
.transform(babel)
.bundle()
.on('error', browserifyError)
.pipe(source('./tests.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./spec/'));
});
gulp.task('style:js', function() {
return gulp.src('./js/**/*.js')
.pipe(notifyError())
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'))
});
gulp.task('hint:js', function() {
return gulp.src('./js/**/*.js')
.pipe(notifyError())
.pipe(jshint({
esnext: true, eqeqeq: true,
linter: require('jshint-jsx').JSXHINT
}))
.pipe(jshint.reporter('fail'))
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('hint:html', function() {
return gulp.src('./app/index.html')
.pipe(notifyError())
.pipe(htmlhint())
.pipe(htmlhint.failReporter());
});
// gulp.task('lint', ['style:js', 'hint:js', 'hint:html']);
gulp.task('watch', function() {
watch('./sass/**/*.scss', function () {
gulp.start('sass');
});
watch(['./js/**/*.js', './package.json'], function () {
gulp.start('browserify');
gulp.start('browserify-test');
});
watch('./app/index.html', function () {
gulp.start('hint:html');
});
watch('./js/**/*.js', function () {
gulp.start('hint:js');
gulp.start('style:js');
});
});
gulp.task('server', ['default'], function () {
return gulp.src('app')
.pipe(server({
livereload: true
}));
});
gulp.task('default', ['sass',
'fonts',
'normalize',
//'lint',
'browserify',
'browserify-test']);
gulp.task('start', ['default', 'watch', 'server']);