This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
73 lines (63 loc) · 1.89 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
require("dotenv").load({ silent: true });
var gulp = require("gulp");
var sass = require("gulp-sass");
var minifyCss = require("gulp-minify-css");
var concat = require("gulp-concat");
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() {
if (environment !== "dev") {
// Minify for non-development
gulp
.src(["app/legacy/src/**/*.js", "app/legacy/views/**/*.js"])
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(ngAnnotate())
.on("error", swallowError)
.pipe(uglify())
.pipe(gulp.dest("app/legacy/build"));
} else {
gulp
.src(["app/legacy/src/**/*.js", "app/legacy/views/**/*.js"])
.pipe(sourcemaps.init())
.pipe(concat("app.js"))
.pipe(ngAnnotate())
.on("error", swallowError)
.pipe(sourcemaps.write())
.pipe(gulp.dest("app/legacy/build"));
}
});
gulp.task("sass", function() {
gulp
.src("app/legacy/stylesheets/site.scss")
.pipe(sass())
.on("error", sass.logError)
.pipe(minifyCss())
.pipe(gulp.dest("app/legacy/build"));
});
gulp.task("build", ["js", "sass"], function() {
// Yup, build the js and sass.
});
gulp.task("watch", ["js", "sass"], function() {
gulp.watch("app/legacy/src/**/*.js", ["js"]);
gulp.watch("app/legacy/views/**/*.js", ["js"]);
gulp.watch("app/legacy/stylesheets/**/*.scss", ["sass"]);
});
gulp.task("server", ["watch"], function() {
nodemon({
script: "app.js",
env: { NODE_ENV: process.env.NODE_ENV || "DEV" },
watch: ["app/server"]
});
});