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:
For config options details, refer to:
Compiler Options
: Configuring compiler options(compilation
field), likeinput
,output
,css compilation
,bundling rules
and so on.Dev Server Options
: Configuring dev server options(server
field), likeport
,host
,protocol
and so on.Shared Options
: Configuring shared options betweencompiler options
anddev server options
, likeroot
,env
and so on.
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
:
Examples
Input and Output
In above example, we configured ./src/index.html
and ./src/about.html
as input, then output the compiled resources to build
dir.