-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
98 lines (83 loc) · 2.6 KB
/
Gulpfile.js
File metadata and controls
98 lines (83 loc) · 2.6 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
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var jscs = require('gulp-jscs');
var watchify = require('watchify');
var reactify = require('reactify');
var debowerify = require('debowerify');
var source = require('vinyl-source-stream');
var spritesmith = require('gulp.spritesmith');
var watchScripts = function() {
var rebundle = function() {
return bundler.bundle({debug: true})
.pipe(source('app.js'))
.pipe(gulp.dest('build/scripts/'));
};
var bundler = watchify({
entries: ['./app/scripts/app.js', './app/jsx/app.jsx'],
extensions: ['.js', '.jsx']
})
// .plugin('minifyify', {
// map: 'app.js.map',
// output: 'build/scripts/app.js.map'
// })
.transform(reactify)
.transform(debowerify)
.on('update', rebundle);
return rebundle();
};
gulp.task('html', function() {
return gulp.src('app/**/*.html')
.pipe(gulp.dest('build'));
});
gulp.task('css', function() {
return gulp.src('app/styles/**/*')
.pipe(sass({
sourceComments: 'map',
errLogToConsole: true,
outputStyle: 'compressed'
}))
.pipe(prefix('last 2 versions', {
map: true,
from: 'main.css.map',
to: 'main.css.map'
}))
.pipe(gulp.dest('build/styles'));
});
gulp.task('jscs', function() {
gulp.src('app/scripts/**/*')
.pipe(jscs());
});
gulp.task('lint', function() {
gulp.src('app/scripts/**/*')
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('js', ['jscs', 'lint'], function() {
watchScripts();
});
gulp.task('images', function () {
var spriteData = gulp.src('images/*.png').pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css'
}));
spriteData.img.pipe(gulp.dest('build/images/'));
spriteData.css.pipe(gulp.dest('build/styles/'));
});
gulp.task('default', ['html', 'css', 'js', 'images'], function() {
console.log('starting browserSync');
browserSync.init(['build/**/*.html', 'build/styles/**/*', 'build/scripts/**/*'], {
server: {
baseDir: './build'
}
});
gulp.watch('app/**/*.html', ['html']);
gulp.watch('app/styles/**/*', ['css']);
gulp.watch('app/scripts/**/*', ['js']);
gulp.watch('app/images/**/*', ['images']);
});