-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (59 loc) · 1.83 KB
/
Copy pathgulpfile.js
File metadata and controls
71 lines (59 loc) · 1.83 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
//gulp stuff i need
var pkg = require('./package.json'),
gulp = require('gulp'),
coffee = require('gulp-coffee'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
wait = require('gulp-wait'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify');
// non-gulp stuff i need
var http = require('http'),
connect = require('connect');
var serverPort = 3000;
var paths = {
source: ['src/**/*.coffee'],
compiled: ['src/**/*.js'],
tests: ['tests/**/*.coffee']
};
//compiles coffee script files
gulp.task('compile', function () {
gulp.src(paths.source)
.pipe(wait(1000))
.pipe(plumber())
.pipe(coffee({bare: true}))
.pipe(gulp.dest('src'));
});
//compresses using uglify
gulp.task('compress', function () {
gulp.src(paths.compiled)
.pipe(plumber())
.pipe(uglify())
.pipe(concat(pkg.name + "_"+ pkg.version +".min.js"))
.pipe(gulp.dest('build'));
});
gulp.task('uncompressed', function () {
//versionless file
gulp.src(paths.compiled)
.pipe(concat(pkg.name + ".js"))
.pipe(gulp.dest('build'));
//versioned file
gulp.src(paths.compiled)
.pipe(concat(pkg.name + "_"+ pkg.version +".js"))
.pipe(gulp.dest('build'));
});
// run a build when src files on change
gulp.task('watch', function () {
gulp.watch(paths.source, ['build']);
gulp.watch(paths.tests, ['build']);
});
// launch this repo as a server (port defined above)
gulp.task('serve', function () {
var app = connect().use(connect.static(__dirname));
http.createServer(app).listen(serverPort);
console.log('test page running at http://localhost:' + serverPort + '/index.html');
});
// builds everything to the `dist` directory
gulp.task('build', ['compile', 'uncompressed', 'compress']);
// runs a build and launches a server
gulp.task('default', ['build', 'watch', 'serve']);