-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgulpfile.js
More file actions
65 lines (50 loc) · 1.57 KB
/
gulpfile.js
File metadata and controls
65 lines (50 loc) · 1.57 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
var gulp = require("gulp");
var browserify = require("gulp-browserify");
var react = require("gulp-react");
var stylus = require("gulp-stylus");
var plumber = require("gulp-plumber");
var nib = require("nib");
var colors = require("colors");
var notifier = require("terminal-notifier");
var shell = require('gulp-shell');
var express = require('express');
var scriptPaths = ["./app/*.jsx", "./app/**/*.jsx", "./app/*.js", "./app/**/*.js"];
var stylePaths = ["./app/*.styl", "./app/**/*.styl"];
var outPath = "./build";
var publicPath = "./";
var notifyError = function(title){
return function(err){
console.log(title);
console.log(err.message.red);
notifier(err.message, {title: title});
};
};
gulp.task("build-scripts", function() {
gulp.src("./app/main.jsx")
.pipe(plumber())
.pipe(browserify({
insertGlobals: true
}))
.on("error", notifyError("Browserify Build Error"))
.pipe(react())
.on("error", notifyError("React Build Error"))
.pipe(gulp.dest(outPath));
});
gulp.task("build-style", function() {
return gulp.src("./app/main.styl")
.pipe(plumber())
.pipe(stylus({use: [nib()]}))
.on("error", notifyError("Stylus Build Error"))
.pipe(gulp.dest(outPath));
});
gulp.task("watch", function() {
gulp.watch(scriptPaths, ["build-scripts"]);
gulp.watch(stylePaths, ["build-style"]);
});
gulp.task("server", function() {
var app = express();
app.use(express.static(publicPath));
app.listen(8000);
});
gulp.task("build", ["build-scripts", "build-style"]);
gulp.task("default", ["build", "watch", "server"]);