Skip to main content

Configuring Farm

Config File Spec

By default, Farm reads the configuration from the farm.config.ts|js|mjs file in the project root directory, an example configuration file:

farm.config.ts

For config options details, refer to:

  • Compiler Options: Configuring compiler options(compilation field), like input, output, css compilation, bundling rules and so on.
  • Dev Server Options: Configuring dev server options(server field), like port, host, protocol and so on.
  • Shared Options: Configuring shared options between compiler options and dev server options, like root, env and so on.
note

You can also use farm start/build -c my-config.ts to use a custom file as config file.

Loading Ts Config File

Farm support load ts config file like farm.config.ts out of box. Farm will bundle farm.config.ts and it's local ts dependencies into farm-config.xxx.mjs file first and load it from disk. Because Farm compiles the farm.config.ts into mjs file, you CAN NOT use __dirname or __filename in your farm.config.ts, use import.meta.url instead.

Or you can use farm.config.mjs or farm.config.cjs with @type to support types avoid bundling farm.config.ts:

farm.config.mjs

Examples

Input and Output

farm.config.ts

In above example, we configured ./src/index.html and ./src/about.html as input, then output the compiled resources to build dir.

Dev Server Port

farm.config.ts

Disable Default Optimizations

farm.config.ts
Extremely Fast Web Build Tool Written in Rust

Copyright © 2024 Farm Community. Built with Docusaurus.