Added start-preview script and server-preview task (#90)
This commit is contained in:
parent
09e9548d25
commit
e798df6200
12
README.md
12
README.md
|
@ -36,6 +36,18 @@ or
|
||||||
gulp server
|
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.
|
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
|
### Static build
|
||||||
|
|
|
@ -20,6 +20,10 @@ const hugoArgsPreview = ["--buildDrafts", "--buildFuture"];
|
||||||
gulp.task("hugo", (cb) => buildSite(cb));
|
gulp.task("hugo", (cb) => buildSite(cb));
|
||||||
gulp.task("hugo-preview", (cb) => buildSite(cb, hugoArgsPreview));
|
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
|
// Build/production tasks
|
||||||
gulp.task("build", ["css", "js", "fonts"], (cb) => buildSite(cb, [], "production"));
|
gulp.task("build", ["css", "js", "fonts"], (cb) => buildSite(cb, [], "production"));
|
||||||
gulp.task("build-preview", ["css", "js", "fonts"], (cb) => buildSite(cb, hugoArgsPreview, "production"));
|
gulp.task("build-preview", ["css", "js", "fonts"], (cb) => buildSite(cb, hugoArgsPreview, "production"));
|
||||||
|
@ -56,7 +60,7 @@ gulp.task('fonts', () => (
|
||||||
));
|
));
|
||||||
|
|
||||||
// Development server with browsersync
|
// Development server with browsersync
|
||||||
gulp.task("server", ["hugo", "css", "js", "fonts"], () => {
|
function runServer() {
|
||||||
browserSync.init({
|
browserSync.init({
|
||||||
server: {
|
server: {
|
||||||
baseDir: "./dist"
|
baseDir: "./dist"
|
||||||
|
@ -66,7 +70,7 @@ gulp.task("server", ["hugo", "css", "js", "fonts"], () => {
|
||||||
gulp.watch("./src/css/**/*.css", ["css"]);
|
gulp.watch("./src/css/**/*.css", ["css"]);
|
||||||
gulp.watch("./src/fonts/**/*", ["fonts"]);
|
gulp.watch("./src/fonts/**/*", ["fonts"]);
|
||||||
gulp.watch("./site/**/*", ["hugo"]);
|
gulp.watch("./site/**/*", ["hugo"]);
|
||||||
});
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run hugo and build the site
|
* Run hugo and build the site
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"build": "gulp build",
|
"build": "gulp build",
|
||||||
"build-preview": "gulp build-preview",
|
"build-preview": "gulp build-preview",
|
||||||
"start": "gulp server",
|
"start": "gulp server",
|
||||||
|
"start-preview": "gulp server-preview",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
Reference in New Issue