Skip to main content

Dev Server Options

DevServer Options - server

Configure the behavior of Farm Dev Server. Example:

type:

port

  • default: 9000

The port the DevServer listens on.

https

  • default: undefined

Enable TLS + HTTP2. The value is options that passes to http2.createSecureServer.

note

Note that a valid certificate is needed if https enabled.

headers

  • default: undefined

Setup global http response headers for the DevServer.

strictPort

  • default: false

By default, Farm will automatically resolve to a new port when given port is used. For example, if 9001 is used, then 9001 will be tried. But if strictPort is true, a error will be thrown when port conflicts, instead of try other ports automatically.

cors

  • default: false

Configure @koa/cors options.

spa

  • default: true

Enable fallback to index.html or not.

hmr

  • default: true for start command, false for other commands

Enable HMR. After enabling the HMR capability, it will monitor the changes of the modules involved in the compilation process. When the modules change, it will automatically trigger recompilation and push the results to Farm Runtime for update. HMR can also be configured through an object, for example:

hmr.port

  • default: 9801

The port the Web Socket server listens on

hmr.host

  • default: localhost

Host on which the Web Socket server listens.

proxy

  • Default value: undefined

Configure server proxy. farm uses http-proxy as a proxy for the development server. Based on http-proxy implementation, specific options refer to its documentation, example:

open

  • default: false

After the compilation is completed, the browser is automatically opened to the corresponding page.

host

  • default: localhost

The host that the Dev Server listens on.

middlewares

  • default: []

Configuring middlewares for the dev server.

Note that a middleware is a function that returns a koa middleware.

writeToDisk

  • default: false

By default the compiled resources are stored and served in memory, set writeToDisk to true to emitted dev resources to the disk.

Extremely Fast Web Build Tool Written in Rust

Copyright © 2024 Farm Community. Built with Docusaurus.