diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-03-14 16:02:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-04-08 13:26:16 +0200 |
commit | 0a56f2af4e1969e76e94fdfb56d1bbed0e685625 (patch) | |
tree | db258649317ea350ce6c56f00483d5655963de16 /commands/server.go | |
parent | 9e360d3844f5077c65649e4c9c98f5cbd1c3efc0 (diff) | |
download | hugo-0a56f2af4e1969e76e94fdfb56d1bbed0e685625.tar.gz hugo-0a56f2af4e1969e76e94fdfb56d1bbed0e685625.zip |
Revert "Revert "Allow rendering static files to disk and dynamic to memory in server mode""
This reverts commit 64b7b7a89753a39661219b2fcb92d7f185a03f63.
Diffstat (limited to 'commands/server.go')
-rw-r--r-- | commands/server.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/commands/server.go b/commands/server.go index bb6a4e15d..23301d004 100644 --- a/commands/server.go +++ b/commands/server.go @@ -50,15 +50,16 @@ type serverCmd struct { // Can be used to stop the server. Useful in tests stop chan bool - disableLiveReload bool - navigateToChanged bool - renderToDisk bool - serverAppend bool - serverInterface string - serverPort int - liveReloadPort int - serverWatch bool - noHTTPCache bool + disableLiveReload bool + navigateToChanged bool + renderToDisk bool + renderStaticToDisk bool + serverAppend bool + serverInterface string + serverPort int + liveReloadPort int + serverWatch bool + noHTTPCache bool disableFastRender bool disableBrowserError bool @@ -109,6 +110,7 @@ of a second, you will be able to save and see your changes nearly instantly.`, cc.cmd.Flags().BoolVar(&cc.renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)") cc.cmd.Flags().BoolVar(&cc.disableFastRender, "disableFastRender", false, "enables full re-renders on changes") cc.cmd.Flags().BoolVar(&cc.disableBrowserError, "disableBrowserError", false, "do not show build errors in the browser") + cc.cmd.Flags().BoolVar(&cc.renderStaticToDisk, "renderStaticToDisk", false, "render static files to disk but dynamic files render to memory.") cc.cmd.Flags().String("memstats", "", "log memory usage to this file") cc.cmd.Flags().String("meminterval", "100ms", "interval to poll memory usage (requires --memstats), valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\".") @@ -147,6 +149,7 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error { cfgInit := func(c *commandeer) (rerr error) { c.Set("renderToMemory", !sc.renderToDisk) + c.Set("renderStaticToDisk", sc.renderStaticToDisk) if cmd.Flags().Changed("navigateToChanged") { c.Set("navigateToChanged", sc.navigateToChanged) } @@ -340,6 +343,8 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string if i == 0 { if f.s.renderToDisk { jww.FEEDBACK.Println("Serving pages from " + absPublishDir) + } else if f.s.renderStaticToDisk { + jww.FEEDBACK.Println("Serving pages from memory and static files from " + absPublishDir) } else { jww.FEEDBACK.Println("Serving pages from memory") } |