Skip to main content
FarmFarm
Version: 1.x
On this page

Svelte

Create a Svelte project based on Farm.

Farm provides two approaches to support creating Svelte projects:

  • Use the create-farm scaffold to create a scaffold project
  • You can manually create a Svelte project following the current documentation

Creating a Svelte Project

sh
npm create farm@latest
sh
yarn create farm@latest
sh
pnpm create farm@latest
sh
bun create farm@latest

Select Svelte template in Select Framework

farm.config.ts
import { defineConfig } from '@farmfe/core'
import { svelte } from '@sveltejs/vite-plugin-svelte'

export default defineConfig({
  vitePlugins: [svelte()],
})

svelte.config.ts
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'

export default {
  preprocess: vitePreprocess(),
}

If you want to start DevServer

sh
npm dev
sh
yarn dev
sh
pnpm dev
sh
bun dev

If you need to run the build production environment product command

sh
npm build
sh
yarn build
sh
pnpm build
sh
bun build

If you need to preview your build product

sh
npm preview
sh
yarn preview
sh
pnpm preview
sh
bun preview

For more example details: Svelte Example

100%

Drag or pinch to explore. Keyboard: + / − zoom, arrows pan, 0 resets, Esc closes.