forked from legomushroom/resize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
152 lines (121 loc) · 3.44 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
var gulp = require('gulp');
var minifycss = require('gulp-minify-css');
var stylus = require('gulp-stylus');
var autoprefixer = require('gulp-autoprefixer');
var notify = require('gulp-notify');
var livereload = require('gulp-livereload');
var coffee = require('gulp-coffee');
var changed = require('gulp-changed');
var jade = require('gulp-jade');
var watch = require('gulp-jade');
var watch = require('gulp-jade');
var coffeelint = require('gulp-coffeelint');
var plumber = require('gulp-plumber');
var uglify = require('gulp-uglify');
var jasminePhantomJs = require('gulp-jasmine2-phantomjs');
var clone = require('gulp-clone');
var rename = require("gulp-rename");
var devFolder = '';
var distFolder = '';
var paths = {
src: {
js: devFolder + 'js/**/*.coffee',
mainJs: devFolder + 'js/any-resize-event.js',
css: devFolder + 'css/**/*.styl',
kit: devFolder + 'css/kit.jade',
index: devFolder + 'index.jade',
partials: devFolder + 'css/partials/**/*.jade',
templates:devFolder + 'templates/**/*.jade',
tests: distFolder + 'spec/**/*.coffee'
},
dist:{
js: distFolder + 'js/',
tests: distFolder + 'spec/',
css: distFolder + 'css/',
kit: distFolder + 'css/',
index: distFolder
}
}
gulp.task('stylus', function(){
return gulp.src(devFolder + 'css/main.styl')
.pipe(stylus())
.pipe(autoprefixer('last 4 version'))
.pipe(minifycss())
.pipe(gulp.dest(paths.dist.css))
.pipe(livereload())
});
gulp.task('coffee', function(e){
return gulp.src(paths.src.js)
.pipe(plumber())
.pipe(changed(paths.src.js))
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffee())
.pipe(gulp.dest(paths.dist.js))
.pipe(livereload())
});
gulp.task('build', function() {
return gulp.src(paths.src.mainJs)
.pipe(clone())
.pipe(gulp.dest('dist/'))
.pipe(uglify({ preserveComments: 'some' }))
.pipe(rename('any-resize-event.min.js'))
.pipe(gulp.dest('dist/'))
});
gulp.task('coffee:tests', function(e){
return gulp.src(paths.src.tests)
.pipe(plumber())
.pipe(changed(paths.src.tests))
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffee())
.pipe(gulp.dest(paths.dist.tests))
.pipe(livereload())
});
gulp.task('test', function(){
return gulp.src('spec/SpecRunner.html')
.pipe(jasminePhantomJs());
});
gulp.task('kit:jade', function(e){
return gulp.src(paths.src.kit)
.pipe(jade({pretty:true}))
.pipe(gulp.dest(paths.dist.kit))
.pipe(livereload())
});
gulp.task('index:jade', function(e){
return gulp.src(paths.src.index)
.pipe(jade({pretty:true}))
.pipe(gulp.dest(paths.dist.index))
.pipe(livereload())
});
gulp.task('default', function(){
var server = livereload();
gulp.watch(paths.src.css, function(e){
gulp.run('stylus');
});
gulp.watch(paths.src.js, function(e){
gulp.run('coffee', 'build');
server.changed(e.path)
});
gulp.watch(paths.src.tests, function(e){
gulp.run('coffee:tests');
server.changed(e.path)
});
gulp.watch(paths.src.kit, function(e){
gulp.run('kit:jade');
server.changed(e.path);
});
gulp.watch(paths.src.index, function(e){
gulp.run('index:jade');
server.changed(e.path);
});
gulp.watch(paths.src.partials, function(e){
gulp.run('kit:jade');
gulp.run('index:jade');
server.changed(e.path);
});
gulp.watch(paths.src.templates, function(e){
gulp.run('index:jade');
server.changed(e.path);
});
});