forked from BrowserSync/browsersync.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
117 lines (103 loc) · 3 KB
/
Copy pathgulpfile.js
File metadata and controls
117 lines (103 loc) · 3 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
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
var gulp = require("gulp");
var fs = require("fs");
var browserSync = require("browser-sync");
var sass = require("gulp-sass");
var minifyCSS = require("gulp-minify-css");
var rename = require("gulp-rename");
var prefix = require("gulp-autoprefixer");
var cp = require("child_process");
var filter = require("gulp-filter");
var crossbow = require("crossbow");
var prettify = require('gulp-jsbeautifier');
var yaml = require('js-yaml');
/**
* Build documentation
*/
gulp.task("docs-build", function (cb) {
return cp.spawn("node", ["_makeDocs"], {stdio: "inherit"}).on("close", cb);
});
/**
* Build the Crossbow Site
*/
gulp.task("crossbow", function () {
return gulp.src([
"_src/*.hbs",
"_src/*.html",
"_src/docs/*"
])
.pipe(crossbow.stream({
cwd: "_src",
prettyUrls: true,
data: {
site: yaml.safeLoad(fs.readFileSync('_config.yml', 'utf8'))
}
}))
.pipe(gulp.dest("./"));
});
/**
* Wait for crossbow-build, then launch the Server
*/
gulp.task("serve", ["sass", "crossbow"], function() {
browserSync({
open: false,
server: {
baseDir: ["./"]
}
});
});
/**
* Wait for crossbow-build, then launch the Server
*/
gulp.task("serve-dist", function() {
browserSync({
open: false,
server: {
baseDir: "./"
}
});
});
gulp.task("dist", ["build", "serve-dist"]);
/**
* Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
*/
gulp.task("sass", function () {
browserSync.notify("Compiling SASS...");
return gulp.src(["_src/scss/core.scss"])
.pipe(sass())
.on("error", function(err){
browserSync.notify(err.message, 3000);
console.log(err.message);
this.emit("end");
})
.pipe(prefix())
.pipe(gulp.dest("css"))
.pipe(minifyCSS({keepBreaks:true}))
.pipe(filter("**/*.css"))
.pipe(rename("core.min.css"))
.pipe(gulp.dest("css"))
.pipe(browserSync.reload({stream:true}));
});
/**
* Watch scss files for changes & recompile
* Watch html/md files, run crossbow & reload BrowserSync
*/
gulp.task("watch", function () {
gulp.watch("_src/scss/**/*", ["sass"]);
gulp.watch(["_src/**", "_config.yml"], ["crossbow", browserSync.reload]);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task("default", ["serve", "watch"]);
/**
* Create documentation from the BrowserSync Source code
*/
gulp.task("docs", function () {
var yuidoc = require("gulp-yuidoc");
return gulp.src(["./node_modules/browser-sync/index.js", "./node_modules/browser-sync/lib/default-config.js"])
.pipe(yuidoc.parser())
.pipe(prettify({mode: 'VERIFY_AND_WRITE'}))
.pipe(gulp.dest("./doc"));
});
gulp.task("build", ["docs", "docs-build", "crossbow", "sass"]);