forked from techx/quill
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
72 lines (61 loc) · 1.94 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
require("dotenv").config();
var gulp = require("gulp");
var sass = require("gulp-sass");
var browserify = require("browserify");
var browserifyNgAnnotate = require("browserify-ngannotate");
var buffer = require("gulp-buffer");
var cleanCss = require("gulp-clean-css");
var concat = require("gulp-concat");
var source = require("vinyl-source-stream");
var sourcemaps = require("gulp-sourcemaps");
var uglify = require("gulp-uglify");
var ngAnnotate = require("gulp-ng-annotate");
var environment = process.env.NODE_ENV;
var nodemon = require("gulp-nodemon");
function swallowError(error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit("end");
}
gulp.task("default", function () {
console.log("yo. use gulp watch or something");
});
gulp.task("js", function () {
var b = browserify({
entries: "app/client/src/app.js",
debug: environment === "dev",
transform: [browserifyNgAnnotate],
});
// transform streaming contents into buffer contents (because gulp-sourcemaps does not support streaming contents)
b.bundle()
.pipe(source("app.js"))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(ngAnnotate())
.on("error", swallowError)
.pipe(sourcemaps.write())
.pipe(gulp.dest("app/client/build"));
});
gulp.task("sass", function () {
gulp
.src("app/client/stylesheets/site.scss")
.pipe(sass())
.on("error", sass.logError)
.pipe(cleanCss())
.pipe(gulp.dest("app/client/build"));
});
gulp.task("build", ["js", "sass"], function () {
// Yup, build the js and sass.
});
gulp.task("watch", ["js", "sass"], function () {
gulp.watch("app/client/src/**/*.js", ["js"]);
gulp.watch("app/client/views/**/*.js", ["js"]);
gulp.watch("app/client/stylesheets/**/*.scss", ["sass"]);
});
gulp.task("server", ["watch"], function () {
nodemon({
script: "app.js",
env: { NODE_ENV: process.env.NODE_ENV || "DEV" },
watch: ["app/server"],
});
});