-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
107 lines (94 loc) · 2.86 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
var gulp = require('gulp'),
jade = require('gulp-jade'),
browserify = require('gulp-browserify'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
prefix = require('gulp-autoprefixer'),
csso = require('gulp-csso'),
rename = require('gulp-rename'),
runSequence = require('run-sequence'),
livereload = require('gulp-livereload'),
gulpif = require('gulp-if');
var DEVELOPMENT = 'development',
PRODUCTION = 'production',
BUILD = "builds/",
LIB = "lib/",
ASSETS = "/assets",
MOCKUPS = "_mockups",
SRC = "_src";
var env = process.env.NODE_ENV || DEVELOPMENT;
if (env!==DEVELOPMENT) env = PRODUCTION;
function getOutputDir() {
return BUILD+env;
}
gulp.task('jade', function() {
var config = {
locals: ""
};
if (env === DEVELOPMENT) {
config.pretty = true;
}
return gulp.src(SRC+"/templates/**/index.jade")
.pipe(jade(config))
.pipe(gulp.dest(getOutputDir()));
});
gulp.task('js', function() {
return gulp.src(SRC+'/js/main.js')
.pipe(browserify({ debug: env === DEVELOPMENT }))
.pipe(gulpif(env === PRODUCTION, uglify()))
.pipe(gulp.dest(getOutputDir()+ASSETS+'/js'));
});
gulp.task('coffee', function() {
gulp.src(SRC+'/coffee/app.coffee', { read: false })
.pipe(browserify({
debug: env === DEVELOPMENT,
transform: ['coffeeify'],
extensions: ['.coffee']
}))
.pipe(gulpif(env === PRODUCTION, uglify()))
.pipe(rename(ASSETS+'/js/app.js'))
.pipe(gulp.dest(getOutputDir()))
});
gulp.task('lib', function() {
gulp.src(SRC+'/coffee/Tus.coffee', { read: false })
.pipe(browserify({
debug: false,
transform: ['coffeeify'],
extensions: ['.coffee'],
ignore: ['jquery']
}))
.pipe(rename('app.js'))
.pipe(gulp.dest(LIB))
});
gulp.task('fonts', function() {
return gulp.src('bower_components/bootstrap-sass/fonts/*')
.pipe(gulp.dest(getOutputDir()+ASSETS+'/fonts'));
});
gulp.task('sass', function() {
var config = {};
if (env === DEVELOPMENT) {
//config.sourceComments = 'map';
} else if (env === PRODUCTION) {
config.outputStyle = 'compressed';
}
return gulp.src(SRC+'/sass/main.scss')
.pipe(sass(config))
.pipe(prefix("last 2 versions", "> 1%", "ie 8", "ie 7", { cascade: true }))
.pipe(gulpif(env === PRODUCTION, csso()))
.pipe(gulp.dest(getOutputDir()+ASSETS+'/css'));
});
gulp.task('watch', function() {
gulp.watch(SRC+'/**/*.jade', ['jade']);
gulp.watch(SRC+'/**/*.coffee', ['coffee']);
gulp.watch(SRC+'/**/*.scss', ['sass']);
var server = livereload();
gulp.watch(BUILD+'**').on('change', function(file) {
server.changed(file.path);
});
});
gulp.task('default', ['fonts', 'coffee', 'jade', 'sass']);
gulp.task('live', ['coffee', 'jade', 'sass', 'watch']);
gulp.task('production', function() {
env = PRODUCTION;
runSequence(['fonts','coffee','jade','sass']);
});