-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
153 lines (139 loc) · 4 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
142
143
144
145
146
147
148
149
150
151
152
153
/*****************************************************************************
*
* Streaming Gulp Build File
*
* @author Kerri Shotts [email protected]
* @version 0.0.1
*
* Copyright (C) 2014 photoKandy Studios LLC and Kerri Shotts. These
* portions are MIT licensed, and are freely available for use and
* distribution.
*
*****************************************************************************/
"use strict";
/* globals require, __dirname */
var gulp = require("gulp");
var browserify = require("browserify");
var sass = require("gulp-sass");
var plumber = require("gulp-plumber");
var tap = require("gulp-tap");
var rename = require("gulp-rename");
var docco = require("gulp-docco");
var bump = require("gulp-bump");
var replace = require("gulp-replace");
var uglify = require("gulp-uglify");
var beautify = require("gulp-beautify");
var gzip = require("gulp-gzip");
var concat = require("gulp-concat");
var pkg = require("./package.json");
var http = require("http");
var st = require("st");
function incVersion(importance) {
return gulp.src(["./package.json"])
.pipe(bump({
type: importance
}))
.pipe(gulp.dest("./"));
}
gulp.task("patch", function() {
return incVersion("patch");
});
gulp.task("feature", function() {
return incVersion("minor");
});
gulp.task("release", function() {
return incVersion("major");
});
//
// copy assets from resources to lib
gulp.task("copy-assets-to-lib", function() {
gulp.src(["resources/ai-export/images/*.png"])
.pipe(gulp.dest("lib/yasmf-assets"));
});
//
// copy assets from lib to dist
gulp.task("preflight", ["copy-assets-to-lib"], function() {
gulp.src(["lib/yasmf-assets/**/*.*"])
.pipe(gulp.dest("dist/yasmf-assets"));
});
function browserifyScripts(debug) {
if (debug === undefined) {
debug = false;
}
return gulp.src(["./lib/yasmf.js"])
.pipe(plumber())
.pipe(tap(function(file) {
file.contents = browserify([file.path], {
fullpaths: true,
standalone: "_y",
debug: debug
})
.bundle();
}))
//.pipe( beautify( {indentSize: 2} ) )
.pipe(rename("yasmf" + (debug ? "-maps" : "") + ".js")) // ends up under dist/yasmf.js
.pipe(gulp.dest("dist"));
}
//
// generate yasmf.js
gulp.task("generate", ["preflight"], function() {
return browserifyScripts();
});
//
// generate yasmf-maps.js
gulp.task("generate-maps", ["preflight", "generate"], function() {
return browserifyScripts(true);
});
/*
gulp.task( "generate-amd", ["generate-maps"], function () {
return gulp.src( ["./_amd/start.js", "./dist/yasmf-browserify.js", "./_amd/end.js"] )
.pipe( concat( "yasmf.js" ) )
.pipe( gulp.dest( "dist" ) );
} );
*/
//
// generate yasmf-min.js
gulp.task("generate-min", ["generate-maps"], function() {
return gulp.src(["./dist/yasmf.js"])
.pipe(uglify())
.pipe(rename(function(path) {
path.basename += "-min";
}))
.pipe(gulp.dest("dist"));
});
//
// generate documentation using docco
gulp.task("doc", function() {
return gulp.src("./lib/**/*.js")
.pipe(docco())
.pipe(gulp.dest("doc"));
});
//
// Convert sass styles (src) to css styles (www)
gulp.task("styles", function() {
return gulp.src(["lib/yasmf.scss"])
.pipe(sass())
.pipe(gulp.dest("dist"));
});
//
// gzip
gulp.task("gzip", ["generate-min", "styles"], function() {
return gulp.src(["dist/yasmf-min.js", "dist/yasmf.css"])
.pipe(gzip())
.pipe(gulp.dest("dist"));
});
//
// Define build
gulp.task("build", ["patch", "gzip", "doc"], function() {});
gulp.task("serve", ["gzip"], function(done) {
return http.createServer(
st({
path: ".",
index: 'index.html',
cache: false
})
).listen(8080, done);
});
//
// Run when gulp is run with no parameters -- builds the project
gulp.task("default", ["generate", "styles", "doc"], function() {});