This repository has been archived by the owner on May 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathgulpfile.js
86 lines (70 loc) · 2.42 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
require("coffee-script").register();
var gulp = require("gulp");
var coffee = require("gulp-coffee");
var gif = require("gulp-if");
var mocha = require("gulp-mocha");
var concat = require("gulp-concat");
var util = require("gulp-util");
var uglify = require("gulp-uglify");
var rjs = require("./src/index.coffee");
var path = require("path");
var through = require("through2");
gulp.task("compile", function (){
return gulp.src("src/**/*.coffee")
.pipe(coffee())
.pipe(gulp.dest("lib"));
});
gulp.task("test", ["compile"], function () {
return gulp.src("test/*_test.coffee")
.pipe(mocha({ reporter : "spec" }));
});
function logger() {
return through.obj(function (file, enc, callback) {
util.log(">>", util.colors.yellow(path.relative(process.cwd(), file.path)));
callback(null, file);
});
}
gulp.task("sample", function () {
return gulp.src("test/fixtures/core/**/*.js")
.pipe(rjs("nested_requirejs"))
.pipe(gulp.dest(".tmp"));
})
gulp.task("example", function () {
return gulp.src("build/{javascripts,bower_components}/**/*.{js,coffee}")
.pipe(gif(function (file) { return path.extname(file.path) == ".coffee"; }, coffee()))
// Traces all modules and outputs them in the correct order. Also wraps shimmed modules.
.pipe(rjs("index", {
configFile : gulp.src("build/javascripts/require_config.coffee").pipe(coffee()),
wrapShim : true,
baseUrl : "build/javascripts",
paths : {
cordova : "empty:",
underscore : "../bower_components/lodash/dist/lodash"
}
}))
.pipe(concat("index.js"))
.pipe(logger())
.pipe(gulp.dest("dist"));
});
gulp.task("example2", function () {
// Traces all modules and outputs them in the correct order. Also wraps shimmed modules.
var source = rjs("main", {
configFile : gulp.src("public/javascripts/require_config.coffee").pipe(coffee()),
wrapShim : true,
baseUrl : "public/javascripts",
paths : {
routes : "empty:"
},
loader : rjs.loader(
function (moduleName) { return path.join("public/javascripts", moduleName + ".{js,coffee}") },
function () { return gif(function (file) { return path.extname(file.path) == ".coffee"; }, coffee()) }
)
});
source.end();
return source
.pipe(concat("main.js"))
.pipe(uglify())
.pipe(gulp.dest("dist"))
.pipe(logger());
});
gulp.task("default", ["compile", "test"]);