2017-11-21 23:12:31 -05:00
|
|
|
// Core packages
|
2016-06-21 13:52:52 -04:00
|
|
|
const gulp = require("gulp"),
|
2017-11-21 19:00:04 -05:00
|
|
|
gutil = require("gulp-util"),
|
|
|
|
plumber = require("gulp-plumber"),
|
2017-11-21 23:12:31 -05:00
|
|
|
concat = require("gulp-concat");
|
|
|
|
|
|
|
|
// Sass packages
|
|
|
|
const sass = require("gulp-sass"),
|
2017-11-21 19:00:04 -05:00
|
|
|
sassGlob = require("gulp-sass-glob"),
|
|
|
|
postCSS = require("gulp-postcss"),
|
2017-11-21 23:12:31 -05:00
|
|
|
autoprefixer = require("autoprefixer");
|
|
|
|
|
|
|
|
// Javascript packages
|
|
|
|
const babel = require("gulp-babel"),
|
2017-11-21 19:00:04 -05:00
|
|
|
stripDebug = require("gulp-strip-debug"),
|
|
|
|
uglify = require("gulp-uglify");
|
2015-07-08 03:34:58 -04:00
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Vue packages
|
|
|
|
const browserify = require("browserify"),
|
|
|
|
vueify = require("vueify"),
|
|
|
|
source = require("vinyl-source-stream"),
|
|
|
|
buffer = require("vinyl-buffer");
|
|
|
|
|
|
|
|
// Determine if gulp has been run with --production
|
|
|
|
const isProduction = gutil.env.production;
|
2015-07-08 03:34:58 -04:00
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Declare plugin settings
|
|
|
|
const sassOutputStyle = isProduction ? "compressed" : "nested",
|
|
|
|
sassPaths = [ "bower_components", "node_modules" ],
|
|
|
|
autoprefixerSettings = { remove: false, cascade: false, browsers: [ "last 6 versions" ] },
|
|
|
|
vuePaths = [ "./bower_components", "./node_modules", "./resources/components", "./resources/assets/js" ];
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Vue file for the public site
|
|
|
|
const vuePublic = "resources/assets/js/app-vue.js";
|
|
|
|
|
|
|
|
// 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",
|
2017-12-19 16:37:34 -05:00
|
|
|
"resources/assets/js/nav.js",
|
2016-05-23 22:35:33 -04:00
|
|
|
"resources/assets/js/contact.js",
|
|
|
|
"resources/assets/js/subscription.js",
|
|
|
|
"resources/assets/js/app.js"
|
2016-01-26 23:20:08 -05:00
|
|
|
];
|
|
|
|
|
2017-11-21 23:12:31 -05: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",
|
2018-01-09 22:00:45 -05:00
|
|
|
"node_modules/popper.js/dist/umd/popper.js",
|
|
|
|
"node_modules/bootstrap/dist/js/bootstrap.js",
|
2017-11-21 18:49:59 -05:00
|
|
|
"node_modules/gsap/src/uncompressed/TweenMax.js",
|
2017-11-21 18:47:31 -05:00
|
|
|
"node_modules/what-input/dist/what-input.js"
|
2015-07-08 03:34:58 -04:00
|
|
|
];
|
|
|
|
|
2017-11-21 23:12:31 -05: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
|
|
|
];
|
|
|
|
|
2017-11-21 23:12:31 -05: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-12-22 00:20:44 -05:00
|
|
|
"bower_components/list.js/dist/list.js",
|
2016-05-23 22:35:33 -04:00
|
|
|
"bower_components/simplemde/dist/simplemde.min.js"
|
2015-07-08 03:34:58 -04:00
|
|
|
];
|
|
|
|
|
2017-11-21 23:12:31 -05: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
|
|
|
];
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Handle errors
|
|
|
|
function handleError(err) {
|
|
|
|
gutil.log(err);
|
2016-05-23 22:35:33 -04:00
|
|
|
this.emit("end");
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Process sass
|
2016-08-16 19:33:02 -04:00
|
|
|
function processSass(filename) {
|
|
|
|
return gulp.src("resources/assets/sass/" + filename + ".scss")
|
2017-11-21 23:12:31 -05:00
|
|
|
.pipe(plumber(handleError))
|
2017-11-21 19:00:04 -05:00
|
|
|
.pipe(sassGlob())
|
2017-11-21 23:12:31 -05:00
|
|
|
.pipe(sass({ outputStyle: sassOutputStyle, includePaths: sassPaths }))
|
2017-11-21 19:00:04 -05:00
|
|
|
.pipe(postCSS([ autoprefixer(autoprefixerSettings) ]))
|
|
|
|
.pipe(concat(filename + ".css"))
|
2016-05-23 22:35:33 -04:00
|
|
|
.pipe(gulp.dest("public/css/"));
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Process vue
|
|
|
|
function processVue(ouputFilename, inputFile) {
|
|
|
|
const javascript = browserify({
|
|
|
|
entries: [ inputFile ],
|
|
|
|
paths: vuePaths
|
|
|
|
}).transform("babelify")
|
|
|
|
.transform(vueify)
|
|
|
|
.bundle()
|
|
|
|
.on("error", handleError)
|
|
|
|
.pipe(source(ouputFilename + ".js"))
|
|
|
|
.pipe(buffer());
|
|
|
|
|
|
|
|
if (isProduction) { javascript.pipe(stripDebug()).pipe(uglify().on("error", handleError)); }
|
|
|
|
return javascript.pipe(gulp.dest("public/js/"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process javascript
|
2016-06-21 13:52:52 -04:00
|
|
|
function processJavaScript(ouputFilename, inputFiles, es6) {
|
|
|
|
const javascript = gulp.src(inputFiles)
|
2017-11-21 23:12:31 -05:00
|
|
|
.pipe(plumber(handleError))
|
2017-11-21 19:00:04 -05:00
|
|
|
.pipe(concat(ouputFilename + ".js"));
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2017-11-21 19:00:04 -05:00
|
|
|
if (es6) { javascript.pipe(babel()); }
|
2017-11-21 23:12:31 -05:00
|
|
|
if (isProduction) { javascript.pipe(stripDebug()).pipe(uglify()); }
|
2016-05-23 22:35:33 -04:00
|
|
|
return javascript.pipe(gulp.dest("public/js/"));
|
2016-03-30 00:51:54 -04:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// 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
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// 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
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Task for public vue
|
|
|
|
gulp.task("js-public-vue", function() {
|
|
|
|
return processVue("app-vue", vuePublic);
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// 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
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// 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
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// 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
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Task to copy fonts
|
2016-08-16 19:47:29 -04:00
|
|
|
gulp.task("fonts", function() {
|
|
|
|
return gulp.src(fontPaths)
|
2017-11-21 23:12:31 -05:00
|
|
|
.pipe(plumber(handleError))
|
2016-08-16 19:47:29 -04:00
|
|
|
.pipe(gulp.dest("public/fonts/"));
|
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Task to run tasks when their respective files are changed
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("watch", function() {
|
2017-11-21 23:12:31 -05:00
|
|
|
const livereload = require("gulp-livereload");
|
2016-03-30 00:51:54 -04:00
|
|
|
|
2017-08-03 19:48:25 -04:00
|
|
|
const liveReloadUpdate = function(files, wait) {
|
2016-03-30 00:51:54 -04:00
|
|
|
setTimeout(function() {
|
2017-11-21 23:12:31 -05:00
|
|
|
livereload.changed(files);
|
2016-03-30 00:51:54 -04:00
|
|
|
}, wait || 1);
|
|
|
|
};
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
livereload.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
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
gulp.watch([ vuePublic, "resources/assets/js/mixins/**/*.js", "resources/components/**/*.vue" ], [ "js-public-vue" ]).on("change", function(files) {
|
|
|
|
liveReloadUpdate(files, 3000);
|
|
|
|
});
|
|
|
|
|
2017-08-03 19:48:25 -04:00
|
|
|
gulp.watch("resources/assets/sass/**/*.scss", [ "sass-public", "sass-dashboard" ]).on("change", function(files) {
|
|
|
|
liveReloadUpdate(files, 1000);
|
2016-03-30 00:51:54 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-11-21 23:12:31 -05:00
|
|
|
// Task to run non-development tasks
|
2016-05-23 22:35:33 -04:00
|
|
|
gulp.task("default", [
|
2016-08-16 19:33:02 -04:00
|
|
|
"sass-public",
|
|
|
|
"sass-dashboard",
|
2017-11-21 23:12:31 -05:00
|
|
|
"js-public-vue",
|
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
|
|
|
]);
|