Environment variables added for gulp tasks, renamed defaultArgs
This commit is contained in:
parent
8979bad9a0
commit
4f7c68fd3b
|
@ -10,13 +10,18 @@ import webpack from "webpack";
|
|||
import webpackConfig from "./webpack.conf";
|
||||
|
||||
const browserSync = BrowserSync.create();
|
||||
const defaultArgs = ["-d", "../dist", "-s", "site", "-v"];
|
||||
|
||||
// Hugo arguments
|
||||
const hugoArgsDefault = ["-d", "../dist", "-s", "site", "-v"];
|
||||
const hugoArgsPreview = ["--buildDrafts", "--buildFuture"];
|
||||
|
||||
// Development tasks
|
||||
gulp.task("hugo", (cb) => buildSite(cb));
|
||||
gulp.task("hugo-preview", (cb) => buildSite(cb, ["--buildDrafts", "--buildFuture"]));
|
||||
gulp.task("hugo-preview", (cb) => buildSite(cb, hugoArgsPreview));
|
||||
|
||||
gulp.task("build", ["css", "js", "hugo"]);
|
||||
gulp.task("build-preview", ["css", "js", "hugo-preview"]);
|
||||
// Build/production tasks
|
||||
gulp.task("build", ["css", "js"], (cb) => buildSite(cb, [], "production"));
|
||||
gulp.task("build-preview", ["css", "js"], (cb) => buildSite(cb, hugoArgsPreview, "production"));
|
||||
|
||||
gulp.task("css", () => (
|
||||
gulp.src("./src/css/*.css")
|
||||
|
@ -50,8 +55,10 @@ gulp.task("server", ["hugo", "css", "js"], () => {
|
|||
gulp.watch("./site/**/*", ["hugo"]);
|
||||
});
|
||||
|
||||
function buildSite(cb, options) {
|
||||
const args = options ? defaultArgs.concat(options) : defaultArgs;
|
||||
function buildSite(cb, options, environment = "development") {
|
||||
const args = options ? hugoArgsDefault.concat(options) : hugoArgsDefault;
|
||||
|
||||
process.env.NODE_ENV = environment;
|
||||
|
||||
return spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => {
|
||||
if (code === 0) {
|
||||
|
|
Reference in New Issue