-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (99 loc) · 2.93 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var gulp = require('gulp');
var jade = require('gulp-jade');
var livereload = require('gulp-livereload');
var plumber = require('gulp-plumber');
var stylus = require('gulp-stylus');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var minify = require('gulp-minify-css');
var environment = 'development';
var paths = {
src: './app/',
dest: './public/',
vendor: './vendor/',
assets: './assets/'
}
gulp.task('set-production', function() {
environment = 'production';
});
gulp.task('assets', function() {
gulp.src(paths.assets + "**")
.pipe(plumber())
.pipe(gulp.dest(paths.dest));
});
gulp.task('vendor-styles', function() {
stream = gulp.src([
paths.vendor + 'styles/bootstrap.css',
paths.vendor + 'styles/bootstrap-theme.css'
])
.pipe(plumber())
.pipe(concat("vendor.css"))
if (environment == 'production') {
stream.pipe(minify())
}
stream.pipe(gulp.dest(paths.dest + 'css/'))
});
gulp.task('vendor-scripts', function() {
stream = gulp.src([
paths.vendor + 'scripts/jquery.js',
paths.vendor + 'scripts/underscore.js',
paths.vendor + 'scripts/backbone.js',
paths.vendor + 'scripts/backbone.syphon.js',
paths.vendor + 'scripts/backbone.marionette.js'
])
.pipe(plumber())
.pipe(concat("vendor.js"))
if (environment == 'production') {
stream.pipe(uglify())
}
stream.pipe(gulp.dest(paths.dest + 'js/'))
});
gulp.task('scripts', function() {
stream = gulp.src(paths.src + 'scripts/index.coffee', { read: false })
.pipe(plumber())
.pipe(browserify({
debug: environment == 'development',
transform: ['coffeeify', 'jadeify'],
extensions: ['.coffee', '.jade']
}))
.pipe(concat('index.js'))
if (environment == 'production') {
stream.pipe(uglify())
}
stream.pipe(gulp.dest(paths.dest + 'js/'))
});
gulp.task('html', function() {
gulp.src(paths.src + 'index.jade')
.pipe(plumber())
.pipe(jade({
pretty: environment == 'development'
}))
.pipe(gulp.dest(paths.dest))
});
gulp.task('styles', function () {
stream = gulp.src(paths.src + 'styles/**/*.styl')
.pipe(plumber())
.pipe(stylus({ use: ['nib']}))
if (environment == 'production') {
stream.pipe(minify())
}
stream.pipe(gulp.dest(paths.dest + 'css/'))
});
gulp.task('watch', function () {
var server = livereload();
gulp.watch(paths.src + 'scripts/**', ['scripts']);
gulp.watch(paths.src + 'styles/**/*.styl', ['styles']);
gulp.watch(paths.src + 'index.jade', ['html']);
gulp.watch([
paths.dest + 'js/*.js',
paths.dest + 'css/*.css',
paths.dest + '**/*.html'
], function(evt) {
server.changed(evt.path);
});
});
gulp.task('vendor', ['vendor-styles', 'vendor-scripts']);
gulp.task('compile', ['html', 'styles', 'scripts']);
gulp.task('default', ['assets', 'vendor', 'compile']);
gulp.task('production', ['set-production', 'default']);