-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
108 lines (93 loc) · 3 KB
/
Copy pathgulpfile.js
File metadata and controls
108 lines (93 loc) · 3 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
"use strict";
/**
* Gulp task definitions.
*/
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var merge = require('merge-stream');
var nodemon = require('gulp-nodemon');
var react = require('gulp-react');
var stylish = require('jshint-stylish');
var tasks = require('gulp-task-listing');
var webpack = require('gulp-webpack');
var compass = require('gulp-compass');
var paths = require('compass-options').paths();
var autoprefixer = require('gulp-autoprefixer');
/******************************************************************************/
/* Utility */
/******************************************************************************/
gulp.task('default', tasks);
var jsFileStream = (function() {
var js = gulp.src("./*.js");
var jsx = gulp.src('./routes/**/*.jsx').pipe(react());
return merge(js, jsx);
})();
/******************************************************************************/
/* Testing */
/******************************************************************************/
gulp.task('lint', function () {
jsFileStream
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'));
});
gulp.task('test', ['lint']);
/******************************************************************************/
/* Styles */
/******************************************************************************/
gulp.task('compass', function () {
return gulp.src(paths.sass + '/**/*.scss')
.pipe(compass({
config_file: 'config.rb',
bundle_exec: true,
sourcemap: false,
time: true,
css: paths.css,
sass: paths.sass,
image: paths.img
}))
.on('error', function() {
// Compass prints the error, so only have to log that we handled it.
console.log('Error caught. Continuing...');
this.emit('end');
})
.pipe(gulp.dest(paths.css));
});
gulp.task('css', ['compass'], function () {
return gulp.src(paths.css + '/main.css')
.pipe(autoprefixer('last 2 versions', '> 5%'))
.pipe(gulp.dest(paths.css));
});
gulp.task('watch', function () {
gulp.watch(paths.sass + '/**/*.scss', ['css']);
});
/******************************************************************************/
/* Compiling */
/******************************************************************************/
gulp.task('webpack', function() {
return gulp.src('browser.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('.'));
});
gulp.task('build', ['test', 'webpack']);
/******************************************************************************/
/* Serving */
/******************************************************************************/
gulp.task('serve', function () {
var env = process.env.NODE_ENV || 'local';
var opts = {
script: 'server.js',
ext: 'js jsx',
ignore: ['public/*'],
env: {
NODE_ENV: env
}
};
nodemon(opts)
.on('start', ['build'])
.on('change', ['build'])
.on('restart', function () {
console.log('restarted!');
});
});
gulp.task('default', ['serve', 'watch']);