Added start-preview script and server-preview task (#90)

This commit is contained in:
Marek Lichtner 2018-05-14 16:16:17 +02:00 committed by Shawn Erquhart
parent 09e9548d25
commit e798df6200
3 changed files with 19 additions and 2 deletions

View File

@ -36,6 +36,18 @@ or
gulp server
```
or for developing your website with `hugo server --buildDrafts --buildFuture`, use:
```bash
npm run start-preview
```
or
```bash
gulp server-preview
```
Then visit http://localhost:3000/ *- or a new browser windows popped-up already -* to preview your new website. BrowserSync will automatically reload the CSS or refresh the whole page, when stylesheets or content changes.
### Static build

View File

@ -20,6 +20,10 @@ const hugoArgsPreview = ["--buildDrafts", "--buildFuture"];
gulp.task("hugo", (cb) => buildSite(cb));
gulp.task("hugo-preview", (cb) => buildSite(cb, hugoArgsPreview));
// Run server tasks
gulp.task("server", ["hugo", "css", "js", "fonts"], (cb) => runServer(cb));
gulp.task("server-preview", ["hugo-preview", "css", "js", "fonts"], (cb) => runServer(cb));
// Build/production tasks
gulp.task("build", ["css", "js", "fonts"], (cb) => buildSite(cb, [], "production"));
gulp.task("build-preview", ["css", "js", "fonts"], (cb) => buildSite(cb, hugoArgsPreview, "production"));
@ -56,7 +60,7 @@ gulp.task('fonts', () => (
));
// Development server with browsersync
gulp.task("server", ["hugo", "css", "js", "fonts"], () => {
function runServer() {
browserSync.init({
server: {
baseDir: "./dist"
@ -66,7 +70,7 @@ gulp.task("server", ["hugo", "css", "js", "fonts"], () => {
gulp.watch("./src/css/**/*.css", ["css"]);
gulp.watch("./src/fonts/**/*", ["fonts"]);
gulp.watch("./site/**/*", ["hugo"]);
});
};
/**
* Run hugo and build the site

View File

@ -9,6 +9,7 @@
"build": "gulp build",
"build-preview": "gulp build-preview",
"start": "gulp server",
"start-preview": "gulp server-preview",
"lint": "eslint src"
},
"author": "",