2016-03-30 00:51:54 -04:00
|
|
|
// include packages
|
2016-06-21 13:52:52 -04:00
|
|
|
const gulp = require("gulp"),
|
2016-05-23 22:35:33 -04:00
|
|
|
gUtil = require("gulp-util"),
|
2016-08-16 19:33:02 -04:00
|
|
|
gSass = require("gulp-sass"),
|
|
|
|
gSassGlob = require("gulp-sass-glob"),
|
2016-05-23 22:35:33 -04:00
|
|
|
gConcat = require("gulp-concat"),
|
|
|
|
gPlumber = require("gulp-plumber"),
|
|
|
|
gUglify = require("gulp-uglify"),
|
|
|
|
gModernizr = require("gulp-modernizr"),
|
2016-06-21 13:52:52 -04:00
|
|
|
gBabel = require("gulp-babel"),
|
2016-06-21 13:40:21 -04:00
|
|
|
gPostCSS = require("gulp-postcss"),
|
2016-08-29 15:49:35 -04:00
|
|
|
gStripDebug = require("gulp-strip-debug"),
|
2016-08-16 19:33:02 -04:00
|
|
|
autoprefixer = require("autoprefixer");
|
2015-07-08 03:34:58 -04:00
|
|
|
|
2016-03-30 00:51:54 -04:00
|
|
|
// determine if gulp has been run with --production
|
2016-06-21 13:52:52 -04:00
|
|
|
const prod = gUtil.env.production;
|
2015-07-08 03:34:58 -04:00
|
|
|
|
2016-06-21 13:40:21 -04:00
|
|
|
// declare plugin settings and modernizr tests
|
2016-08-16 19:33:02 -04:00
|
|
|
const sassOutputStyle = prod ? "compressed" : "nested",
|
|
|
|
sassIncludePaths = [ "bower_components" ],
|
2016-06-21 13:40:21 -04:00
|
|
|
autoprefixerSettings = { remove: false, cascade: false, browsers: [ "last 6 versions" ] },
|
2016-05-23 22:35:33 -04:00
|
|
|
modernizrTests = [];
|
2016-03-30 00:51:54 -04:00
|
|
|
|
|
|
|
// javascript files for the public site
|
2016-06-21 13:52:52 -04:00
|
|
|
const jsPublic = [
|
2016-05-23 22:35:33 -04:00
|
|
|
"resources/assets/js/site-vars.js",
|
|
|
|
"resources/assets/js/contact.js",
|
|
|
|
"resources/assets/js/subscription.js",
|
|
|
|
"resources/assets/js/app.js"
|
2016-01-26 23:20:08 -05:00
|
|
|
];
|
|
|
|
|
2016-03-30 00:51:54 -04:00
|
|
|
// javascript libraries for the public site
|
2016-06-21 13:52:52 -04:00
|
|
|
const jsPublicLibs = [
|
2016-08-01 22:38:22 -04:00
|
|
|
"bower_components/jquery/dist/jquery.js",
|
2016-08-16 19:33:02 -04:00
|
|
|
"bower_components/bootstrap-sass/assets/javascripts/bootstrap.js",
|
2016-05-23 22:35:33 -04:00
|
|
|
"bower_components/jQuery.stickyFooter/assets/js/jquery.stickyfooter.js"
|
2015-07-08 03:34:58 -04:00
|
|
|
];
|
|
|
|
|
2016-03-30 00:51:54 -04:00
|
|
|
// javascript files for the dashboard
|
2016-06-21 13:52:52 -04:00
|
|
|
const jsDashboard = [
|
2016-05-23 22:35:33 -04:00
|
|
|
"resources/assets/js/dashboard.js"
|
2015-07-08 03:34:58 -04:00
|
|
|
];
|
|
|
|
|
2016-03-30 00:51:54 -04:00
|
|
|
// javascript libraries for the dashboard
|
2016-06-21 13:52:52 -04:00
|
|
|
const jsDashboardLibs = [
|
2016-08-01 22:38:22 -04:00
|
|
|
"bower_components/jquery/dist/jquery.js",
|
2016-08-16 19:33:02 -04:00
|
|
|
"bower_components/bootstrap-sass/assets/javascripts/bootstrap.js",
|
2016-05-23 22:35:33 -04:00
|
|
|
"bower_components/Sortable/Sortable.js",
|
2016-08-01 22:38:22 -04:00
|
|
|
"bower_components/datetimepicker/build/jquery.datetimepicker.full.js",
|
2016-05-23 22:35:33 -04:00
|
|
|
"bower_components/simplemde/dist/simplemde.min.js"
|
2015-07-08 03:34:58 -04:00
|
|
|
];
|
|
|
|
|
2016-03-30 00:51:54 -04:00
|
|
|
// paths to folders containing fonts that should be copied to public/fonts/
|
2016-06-21 13:52:52 -04:00
|
|
|
const fontPaths = [
|
2016-05-23 22:35:33 -04:00
|
|
|
"resources/assets/fonts/**",
|
2016-08-16 19:33:02 -04:00
|
|
|
"bower_components/bootstrap-sass/assets/fonts/**/*",
|
2016-08-01 23:02:16 -04:00
|
|
|
"bower_components/fontawesome/fonts/**"
|
2016-03-30 00:51:54 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
// function to handle gulp-plumber errors
|
|
|
|
function plumberError(err) {
|
|
|
|
console.log(err);
|
2016-05-23 22:35:33 -04:00
|
|
|
this.emit("end");
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
2016-08-16 19:33:02 -04:00
|
|
|
// function to handle the processing of sass files
|
|
|
|
function processSass(filename) {
|
|
|
|
return gulp.src("resources/assets/sass/" + filename + ".scss")
|
2016-03-30 00:51:54 -04:00
|
|
|
.pipe(gPlumber(plumberError))
|
2016-08-16 19:33:02 -04:00
|
|
|
.pipe(gSassGlob())
|
|
|
|
.pipe(gSass({ outputStyle: sassOutputStyle, includePaths: sassIncludePaths }))
|
2016-06-21 13:40:21 -04:00
|
|
|
.pipe(gPostCSS([ autoprefixer(autoprefixerSettings) ]))
|
2016-05-23 22:35:33 -04:00
|
|
|
.pipe(gConcat(filename + ".css"))
|
|
|
|
.pipe(gulp.dest("public/css/"));
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// function to handle the processing of javascript files
|
2016-06-21 13:52:52 -04:00
|
|
|
function processJavaScript(ouputFilename, inputFiles, es6) {
|
|
|
|
const javascript = gulp.src(inputFiles)
|
2016-03-30 00:51:54 -04:00
|
|
|
.pipe(gPlumber(plumberError))
|
2016-05-23 22:35:33 -04:00
|
|
|
.pipe(gConcat(ouputFilename + ".js"));
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2016-06-21 13:52:52 -04:00
|
|
|
if (es6) { javascript.pipe(gBabel({ presets: [ "es2015" ] })); }
|
2016-08-29 15:49:35 -04:00
|
|
|
if (prod) { javascript.pipe(gStripDebug()).pipe(gUglify()); }
|
2016-05-23 22:35:33 -04:00
|
|
|
return javascript.pipe(gulp.dest("public/js/"));
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// gulp task for public styles
|
2016-08-16 19:33:02 -04:00
|
|
|
gulp.task("sass-public", function() {
|
|
|
|
return processSass("app");
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// gulp task for dashboard styles
|
2016-08-16 19:33:02 -04:00
|
|
|
gulp.task("sass-dashboard", function() {
|
|
|
|
return processSass("dashboard");
|
2015-07-08 03:34:58 -04:00
|
|
|
});
|
2016-03-30 00:51:54 -04:00
|
|
|
|
|
|
|
// gulp task for public javascript
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("js-public", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
return processJavaScript("app", jsPublic, true);
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// gulp task for public javascript libraries
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("js-public-libs", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
return processJavaScript("lib", jsPublicLibs, false);
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// gulp task for dashboard javascript
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("js-dashboard", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
return processJavaScript("dashboard", jsDashboard, true);
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// gulp task for dashboard javascript libraries
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("js-dashboard-libs", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
return processJavaScript("lib-dashboard", jsDashboardLibs, false);
|
2016-05-23 22:35:33 -04:00
|
|
|
});
|
|
|
|
|
2016-08-16 19:47:29 -04:00
|
|
|
// gulp task to copy fonts
|
|
|
|
gulp.task("fonts", function() {
|
|
|
|
return gulp.src(fontPaths)
|
|
|
|
.pipe(gPlumber(plumberError))
|
|
|
|
.pipe(gulp.dest("public/fonts/"));
|
|
|
|
});
|
|
|
|
|
2016-05-23 22:35:33 -04:00
|
|
|
// gulp task for modernizr
|
|
|
|
gulp.task("modernizr", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
const modernizr = gulp.src([ "public/js/lib.js", "public/js/app.js", "public/css/app.css" ])
|
|
|
|
.pipe(gModernizr({
|
|
|
|
tests: modernizrTests,
|
|
|
|
excludeTests: [ "hidden" ],
|
|
|
|
crawl: false,
|
|
|
|
options: [ "setClasses", "addTest", "html5printshiv", "testProp", "fnBind" ]
|
|
|
|
}))
|
2016-05-23 22:35:33 -04:00
|
|
|
.pipe(gPlumber(plumberError))
|
|
|
|
.pipe(gConcat("modernizr.js"));
|
|
|
|
|
|
|
|
// minify if running gulp with --production
|
|
|
|
if (prod) { modernizr.pipe(gUglify()); }
|
|
|
|
return modernizr.pipe(gulp.dest("public/js/"));
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
// gulp watch task
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("watch", function() {
|
2016-06-21 13:52:52 -04:00
|
|
|
const gLiveReload = require("gulp-livereload");
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2016-06-21 13:52:52 -04:00
|
|
|
const liveReloadUpdate = function(wait) {
|
2016-03-30 00:51:54 -04:00
|
|
|
setTimeout(function() {
|
2016-05-23 22:35:33 -04:00
|
|
|
gLiveReload.changed(".");
|
2016-03-30 00:51:54 -04:00
|
|
|
}, wait || 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
gLiveReload.listen();
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.watch(jsPublic, [ "js-public" ]).on("change", liveReloadUpdate);
|
|
|
|
gulp.watch(jsDashboard, [ "js-dashboard" ]).on("change", liveReloadUpdate);
|
2016-08-23 22:32:16 -04:00
|
|
|
gulp.watch([ "app/**/*.php", "routes/**/*.php", "resources/views/**/*.blade.php" ]).on("change", liveReloadUpdate);
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2016-08-16 19:33:02 -04:00
|
|
|
gulp.watch("resources/assets/sass/**/*.scss", [ "sass-public", "sass-dashboard" ]).on("change", function() {
|
2016-03-30 00:51:54 -04:00
|
|
|
liveReloadUpdate(1000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// gulp default task
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("default", [
|
2016-08-16 19:33:02 -04:00
|
|
|
"sass-public",
|
|
|
|
"sass-dashboard",
|
2016-05-23 22:35:33 -04:00
|
|
|
"js-public",
|
|
|
|
"js-public-libs",
|
|
|
|
"js-dashboard",
|
|
|
|
"js-dashboard-libs",
|
|
|
|
"fonts"
|
2016-03-30 00:51:54 -04:00
|
|
|
]);
|