aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Calavera <david.calavera@gmail.com>2016-09-01 10:04:47 -0700
committerGitHub <noreply@github.com>2016-09-01 10:04:47 -0700
commitd750ef3af85183b80731ecaa14d5a3e0bd31fdc7 (patch)
tree976e695766217b3f445f639c26f300598a7a425d
parent7c04c37162c859ce373f9a458536e27358ac16fd (diff)
parent24819804aa2d37dc8b0d3e8220b285f2766a9aca (diff)
Merge pull request #3 from netlify/add_deploy_context
Add deploy preview context.
-rw-r--r--gulpfile.babel.js24
-rw-r--r--netlify.toml7
-rw-r--r--package.json1
3 files changed, 19 insertions, 13 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 62e65d0..b3c942c 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -10,20 +10,13 @@ import webpackConfig from "./webpack.conf";
const browserSync = BrowserSync.create();
const hugoBin = "hugo";
+const defaultArgs = ["-d", "../dist", "-s", "site", "-v"];
-gulp.task("hugo", (cb) => {
- const args = ["-d", "../dist", "-s", "site", "-v"];
- return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", (code) => {
- if (code === 0) {
- browserSync.reload();
- } else {
- browserSync.notify("Hugo build failed :(");
- }
- cb();
- });
-});
+gulp.task("hugo", (cb) => buildSite(cb));
+gulp.task("hugo-preview", (cb) => buildSite(cb, ["--buildDrafts", "--buildFuture"]));
gulp.task("build", ["css", "js", "hugo"]);
+gulp.task("build-preview", ["css", "js", "hugo-preview"]);
gulp.task("css", () => (
gulp.src("./src/css/*.css")
@@ -56,3 +49,12 @@ gulp.task("server", ["hugo", "css", "js"], () => {
gulp.watch("./src/css/**/*.css", ["css"]);
gulp.watch("./site/**/*", ["hugo"]);
});
+
+function buildSite(cb, options) {
+ const args = options ? defaultArgs.concat(options) : defaultArgs;
+
+ return cp.spawn(hugoBin, args, {stdio: "inherit"}).on("close", () => {
+ browserSync.reload();
+ cb();
+ });
+}
diff --git a/netlify.toml b/netlify.toml
index efcfd06..dd1ef8e 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -1,3 +1,6 @@
[build]
-command = "npm run build"
-publish = "dist"
+ command = "npm run build"
+ publish = "dist"
+
+[context.deploy-preview]
+ command = "npm run build-preview"
diff --git a/package.json b/package.json
index 67a3ab0..f82f02b 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"hugo": "gulp hugo",
"webpack": "gulp webpack",
"build": "gulp build",
+ "build-preview": "gulp build-preview",
"start": "gulp server",
"lint": "eslint src"
},