This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
74 lines (64 loc) · 1.84 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var path = require('path');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var lint = require('gulp-eslint');
var less = require('gulp-less');
var config = {
paths: {
js: './src/**/*.js',
jsx: './src/**/*.jsx',
appJs: [
'./src/app.jsx'
],
less: './src/assets/less/**/*.less',
html: './src/**/*.html',
dist: './dist'
}
}
// Compile React Components to JS
gulp.task('js', function() {
browserify(config.paths.appJs)
.transform(reactify)
.bundle()
.on('error', console.error.bind(console))
.pipe(source('bundle.js'))
.pipe(gulp.dest(config.paths.dist + '/scripts'));
});
// Lint js files for JS coding quality
gulp.task('lint', function() {
return gulp.src(config.paths.jsx)
.pipe(lint.format());
});
// Automatically recompile the react components and relint the JS
gulp.task('watchjsx', function() {
gulp.watch(config.paths.jsx, ['js','lint']);
});
gulp.task('watchjs', function() {
gulp.watch(config.paths.js, ['js', 'lint']);
});
// Compile Less Files to a bundled Css File
gulp.task('less', function() {
return gulp.src(config.paths.less)
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(concat('site.css'))
.pipe(gulp.dest(config.paths.dist + '/css'));
});
// Compile Less files whenever a css file is changed
gulp.task('watchcss', function() {
gulp.watch(config.paths.less, ['less']);
});
// Move HTML files to the Dist folder
gulp.task('html', function () {
gulp.src(config.paths.html)
.pipe(gulp.dest(config.paths.dist));
});
// Move HTML files to Dist when written
gulp.task('watchhtml', function() {
gulp.watch(config.paths.html, ['html']);
});
gulp.task('default', ['less','js','lint','watchjs', 'watchjsx', 'watchcss', 'html', 'watchhtml']);