Quick Start
Farm needs Node 16.18.0 and above.
Online experienceâ
Create a Farm Projectâ
npm create farm@latest
You can also directly specify the project name and the template you want to use via additional command line options:
npm create farm farm-app --template react
2. Start the Projectâ
Choose the package manager you like, install dependencies, then start the project. Then, start the project:
cd farm-app && npm install && npm start
The project will start at http://localhost:9000
by default.
3. Configuring the Projectâ
The project is configured by farm.config.ts/js/mjs
file in the root directory of the project.
import { defineConfig } from "@farmfe/core";
export default defineConfig({
// Options related to the compilation
compilation: {
input: {
// can be a relative path or an absolute path
index: "./index.html",
},
output: {
path: "./build",
publicPath: "/",
},
// ...
},
// Options related to the dev server
server: {
port: 9000,
// ...
},
// Additional plugins
plugins: [],
});
See Configuring Farm for details.
4. Building the projectâ
Build the Farm project as production-ready static files:
npm run build
The built product is downgraded to ES2017
by default, and the product will be compressed and Tree Shake. If you want to preview the build product locally, you can execute npm run preview
or npx farm preview
.
See Build For Production for details.