Quick Start
Farm needs Node 16.19.0 and above.
Online experienceâ
Create a Farm Projectâ
- npm
- yarn
- pnpm
npm create farm@latest
yarn create farm
pnpm create farm
You can also directly specify the project name and the template you want to use via additional command line options:
- npm 6.x
- npm 7+
- yarn
- pnpm
npm create farm@latest my-vue-app --template react
npm create farm@latest my-vue-app -- --template vue
yarn create farm my-vue-app --template react
pnpm create farm my-vue-app --template vue
2. Start the Projectâ
Choose the package manager you like, then the dependencies will be installed automatically. Then, start the project:
- npm
- yarn
- pnpm
cd farm-project && npm start
cd farm-project && yarn start
cd farm-project && pnpm 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: [],
});
Refer to Config Reference for more details of configuring Farm.
4. Building the projectâ
Build the Farm project as production-ready static files:
npm run build
The built product is downgraded to ES5 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
.