-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
98 lines (87 loc) · 2.73 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var nodemon = require('gulp-nodemon');
var jscs = require('gulp-jscs');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var stylus = require('gulp-stylus');
var minifyCSS = require('gulp-minify-css');
var del = require('del');
var fs = require('fs');
var assets = {
scripts: {
client: [
'client/**/*.js'
],
clientVendors: [
'node_modules/ym/modules.js',
'node_modules/mustache/mustache.js',
'node_modules/vow/vow.min.js',
'node_modules/inherit/lib/inherit.js',
'node_modules/bla/blocks/bla-error/*.js',
'node_modules/bla/blocks/bla/*.js'
],
server: [
'server/**/*.js',
'api/**/*.js',
'api-stub/**/*.js'
]
},
styles: ['client/**/*.styl']
};
gulp.task('clean', function (cb) {
del(['build'], cb);
});
gulp.task('build', ['scripts', 'styles']);
gulp.task('scripts', ['clean'], function () {
return gulp.src([].concat(assets.scripts.clientVendors, assets.scripts.client))
.pipe(sourcemaps.init())
.pipe(cached('scripts'))
.pipe(uglify())
.pipe(remember())
.pipe(concat('scripts.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build'));
});
gulp.task('styles', ['clean'], function () {
return gulp.src(assets.styles)
.pipe(stylus())
.pipe(minifyCSS())
.pipe(concat('styles.min.css'))
.pipe(gulp.dest('build'));
});
gulp.task('test', ['lint-client', 'lint-server']);
gulp.task('lint-client', function (cb) {
return gulp.src(assets.scripts.client)
.pipe(cached('linting'))
.pipe(jshint('./client/.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.pipe(jscs());
});
gulp.task('lint-server', function (cb) {
return gulp.src(assets.scripts.server)
.pipe(cached('linting'))
.pipe(jshint('./server/.jshintrc'))
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.pipe(jscs());
});
gulp.task('environment', function (cb) {
var environment = process.env.NODE_ENV || 'development';
del('configs/current', {force: true}, function () {
fs.symlink(environment, 'configs/current');
});
});
gulp.task('dev', ['build'], function () {
nodemon({
script: 'server/app.js',
ext: 'html js styl',
ignore: ['./.git/**', './build/**', './node_modules/**']
})
.on('change', ['build']);
});