2016-02-26 15:36:00 +00:00
|
|
|
var async = require("async");
|
|
|
|
var es = require("event-stream");
|
|
|
|
var fs = require("fs");
|
|
|
|
var gulp = require("gulp");
|
|
|
|
var templateCache = require("gulp-angular-templatecache");
|
|
|
|
var clean = require("gulp-clean");
|
|
|
|
var concat = require("gulp-concat");
|
|
|
|
var cssBase64 = require("gulp-css-base64");
|
|
|
|
var gulpIf = require("gulp-if");
|
2016-10-02 17:23:29 +00:00
|
|
|
var cleanCss = require("gulp-clean-css");
|
2016-02-26 15:36:00 +00:00
|
|
|
var newer = require("gulp-newer");
|
|
|
|
var ngAnnotate = require("gulp-ng-annotate");
|
|
|
|
var replace = require("gulp-replace");
|
|
|
|
var uglify = require("gulp-uglify");
|
|
|
|
var mainBowerFiles = require("main-bower-files");
|
|
|
|
var combine = require("stream-combiner");
|
2016-10-02 17:23:29 +00:00
|
|
|
var sourcemaps = require("gulp-sourcemaps");
|
2016-10-07 11:57:20 +00:00
|
|
|
var inject = require("gulp-inject");
|
2016-10-07 11:30:15 +00:00
|
|
|
var img64 = require("./gulpfile-img64");
|
2016-10-18 11:27:20 +00:00
|
|
|
var path = require("path");
|
2016-02-26 15:36:00 +00:00
|
|
|
|
|
|
|
var files = [
|
2016-10-02 18:03:24 +00:00
|
|
|
"app/**/*.js",
|
|
|
|
"app/**/*.css",
|
2016-10-12 10:51:16 +00:00
|
|
|
"app/**/*.html",
|
|
|
|
"assets/**/*.css"
|
2016-02-26 15:36:00 +00:00
|
|
|
];
|
|
|
|
|
2016-10-07 11:57:20 +00:00
|
|
|
gulp.task("default", [ "index" ]);
|
2016-02-26 15:36:00 +00:00
|
|
|
|
|
|
|
gulp.task("clean", function() {
|
|
|
|
return combine(
|
|
|
|
gulp.src("build"),
|
|
|
|
clean()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("deps", function() {
|
|
|
|
return combine(
|
2016-10-18 11:27:20 +00:00
|
|
|
gulp.src(mainBowerFiles({ paths: { bowerDirectory: __dirname + '/../bower_components', bowerJson: __dirname + '/../bower.json' } }), { base: path.resolve(__dirname + "/..") + "/" }),
|
2016-02-26 15:36:00 +00:00
|
|
|
gulpIf([ "**/*.js", "**/*.css" ], combine(
|
|
|
|
gulpIf("**/*.js", combine(
|
|
|
|
newer("build/dependencies.js"),
|
2016-10-03 14:38:21 +00:00
|
|
|
sourcemaps.init({ loadMaps: true }),
|
2016-02-26 15:36:00 +00:00
|
|
|
concat("dependencies.js"),
|
2016-10-02 17:23:29 +00:00
|
|
|
uglify(),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
2016-02-26 15:36:00 +00:00
|
|
|
)),
|
|
|
|
gulpIf("**/*.css", combine(
|
|
|
|
newer("build/dependencies.css"),
|
2016-10-03 14:38:21 +00:00
|
|
|
gulpIf("**/bower_components/bootstrap/**", combine(
|
|
|
|
replace("src: url('../fonts/glyphicons-halflings-regular.eot');", ""),
|
|
|
|
replace(/src: url\('\.\.\/fonts\/glyphicons-halflings-regular\..*/g, "src: url('../fonts/glyphicons-halflings-regular.ttf') format('truetype');")
|
|
|
|
)),
|
|
|
|
cssBase64({ maxWeightResource: 1000000 }),
|
|
|
|
sourcemaps.init({ loadMaps: true }),
|
2016-02-26 15:36:00 +00:00
|
|
|
concat("dependencies.css"),
|
2016-10-02 17:23:29 +00:00
|
|
|
cleanCss(),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
2016-02-26 15:36:00 +00:00
|
|
|
)),
|
|
|
|
gulp.dest("build")
|
|
|
|
))
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("app", function() {
|
|
|
|
return combine(
|
|
|
|
gulp.src(files, { base: process.cwd() + "/" }),
|
2016-10-07 11:30:15 +00:00
|
|
|
gulpIf("**/*.html", combine(
|
|
|
|
img64(),
|
|
|
|
templateCache({ module: "facilpad", base: process.cwd() + "/app/" })
|
|
|
|
)),
|
2016-02-26 15:36:00 +00:00
|
|
|
gulpIf("**/*.js", combine(
|
|
|
|
newer("build/app.js"),
|
2016-10-02 17:23:29 +00:00
|
|
|
sourcemaps.init(),
|
2016-02-26 15:36:00 +00:00
|
|
|
concat("app.js"),
|
|
|
|
ngAnnotate(),
|
2016-10-02 17:23:29 +00:00
|
|
|
uglify(),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
2016-02-26 15:36:00 +00:00
|
|
|
)),
|
|
|
|
gulpIf("**/*.css", combine(
|
|
|
|
newer("build/app.css"),
|
|
|
|
cssBase64({ maxWeightResource: 1000000 }),
|
2016-10-02 17:23:29 +00:00
|
|
|
sourcemaps.init(),
|
2016-02-26 15:36:00 +00:00
|
|
|
concat("app.css"),
|
2016-10-02 17:23:29 +00:00
|
|
|
cleanCss(),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
2016-02-26 15:36:00 +00:00
|
|
|
)),
|
|
|
|
gulp.dest("build")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-10-07 11:57:20 +00:00
|
|
|
gulp.task("all", [ "deps", "app" ], function() {
|
|
|
|
return combine(
|
|
|
|
es.merge(
|
2016-02-26 15:36:00 +00:00
|
|
|
combine(
|
2016-10-07 11:57:20 +00:00
|
|
|
gulp.src([ "build/dependencies.js", "build/app.js" ]),
|
|
|
|
newer("build/all.js"),
|
|
|
|
sourcemaps.init({ loadMaps: true }),
|
|
|
|
concat("all.js"),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
|
|
|
),
|
2016-02-26 15:36:00 +00:00
|
|
|
combine(
|
2016-10-07 11:57:20 +00:00
|
|
|
gulp.src([ "build/dependencies.css", "build/app.css" ]),
|
|
|
|
newer("build/all.css"),
|
|
|
|
sourcemaps.init({ loadMaps: true }),
|
|
|
|
concat("all.css"),
|
|
|
|
sourcemaps.write("./sourcemaps")
|
2016-10-18 11:27:20 +00:00
|
|
|
),
|
|
|
|
gulp.src("deref.html")
|
2016-10-07 11:57:20 +00:00
|
|
|
),
|
|
|
|
gulp.dest("build")
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task("index", [ "all" ], function() {
|
|
|
|
return combine(
|
|
|
|
gulp.src("index.html"),
|
|
|
|
img64(),
|
2016-10-18 11:27:20 +00:00
|
|
|
concat("build/index.html"),
|
2016-10-07 11:57:20 +00:00
|
|
|
inject(gulp.src([ "build/all.js", "build/all.css" ], { read: false }), { relative: true, removeTags: true }),
|
2016-10-18 11:27:20 +00:00
|
|
|
gulp.dest(".")
|
2016-10-07 11:57:20 +00:00
|
|
|
);
|
2016-02-26 15:36:00 +00:00
|
|
|
});
|
|
|
|
|
2016-10-07 11:57:20 +00:00
|
|
|
gulp.task("watch", [ "index" ], function() {
|
|
|
|
gulp.watch([ "index.html", "bower.json" ].concat(files), [ "index" ]);
|
2016-02-26 15:36:00 +00:00
|
|
|
});
|