Skip to main content

DevServer and HMR

Farm provides DevServer and enabled HMR in development by default.

Configuring Dev Server

Farm provides a lot of useful options to configure dev server. All dev server options are configured by server.

note

If you are built tools on top of farm, refer to Javascript API for creating a Dev Server programmatically.

Dev Server Middlewares

You can use middlewares to handle dev server requests. For example:

farm.config.ts

In above example, a Farm middleware is a function that expose Koa Middleware. Common Koa middlewares can be used directly, for example:

Hot Module Replacement(HMR)

Farm provides a Vite-compatible HMR API. If you are framework authors, leverage the API to update your Application instance, precise without reloading the page.

  • For React, React Refresh are enabled automatically by official plugins @farmfe/plugin-react.
  • For Vue, Solid and other frameworks, it's HMR are supported by there plugins like @vitejs/plugin-vue, vite-plugin-solid and so on.

Farm provides official templates that set all these capabilities up already, create an app via create-farm then all HMR abilities are ready.

note
Extremely Fast Web Build Tool Written in Rust

Copyright © 2024 Farm Community. Built with Docusaurus.