-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add quick start and why farm, construct doc structure * chore: adjust reame * fix: build error
- Loading branch information
Showing
45 changed files
with
5,138 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,14 @@ | ||
# Website | ||
# Farm docs | ||
Docs site of Farm. | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true yarn deploy | ||
Install dependencies: | ||
```bash | ||
pnpm i | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> yarn deploy | ||
Development locally: | ||
```bash | ||
npm start | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. | ||
Merge the changes to main will automatically publish to github pages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# CLI Options | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
|
||
# Config Reference | ||
Farm loads config from `farm.config.ts` or `farm.config.js` file under the project root, recommend to use `farm.config.ts` to get typing support easily. | ||
|
||
The config file look like: | ||
|
||
```ts | ||
import { defineFarmConfig } from '@farmfe/core/dist/config'; | ||
|
||
export default defineFarmConfig({ | ||
root: process.cwd(), // config project root | ||
// Options related compilation | ||
compilation: { | ||
// ... | ||
}, | ||
// Options related to dev server | ||
server: { | ||
hmr: true, | ||
// ... | ||
}, | ||
// Additional plugins | ||
plugins: [] | ||
}); | ||
``` | ||
|
||
## Compilation Options | ||
> The detail of each option will be completed later | ||
```ts | ||
import { defineFarmConfig } from '@farmfe/core/dist/config'; | ||
|
||
export default defineFarmConfig({ | ||
// Options related compilation | ||
compilation: CompilationOptions; | ||
// .. | ||
}); | ||
|
||
interface CompilationOptions { | ||
input?: Record<string, string>; | ||
output?: { | ||
filename?: string; | ||
path?: string; | ||
publicPath?: string; | ||
}; | ||
resolve?: { | ||
extensions?: string[]; | ||
alias?: Record<string, string>; | ||
mainFields?: string[]; | ||
conditions?: string[]; | ||
symlinks: boolean; | ||
}; | ||
external?: string[]; | ||
mode?: 'development' | 'production'; | ||
runtime?: { | ||
plugins?: string[]; // custom runtime plugin | ||
}; | ||
// Options parsed to swc | ||
script?: { | ||
// specify target es version | ||
target?: | ||
| 'es3' | ||
| 'es5' | ||
| 'es2015' | ||
| 'es2016' | ||
| 'es2017' | ||
| 'es2018' | ||
| 'es2019' | ||
| 'es2020' | ||
| 'es2021' | ||
| 'es2022'; | ||
// config swc parser | ||
parser?: { | ||
esConfig?: { | ||
jsx?: boolean; | ||
fnBind: boolean; | ||
// Enable decorators. | ||
decorators: boolean; | ||
|
||
// babel: `decorators.decoratorsBeforeExport` | ||
// | ||
// Effective only if `decorators` is true. | ||
decoratorsBeforeExport: boolean; | ||
exportDefaultFrom: boolean; | ||
// Stage 3. | ||
importAssertions: boolean; | ||
privateInObject: boolean; | ||
allowSuperOutsideMethod: boolean; | ||
allowReturnOutsideFunction: boolean; | ||
}; | ||
tsConfig?: { | ||
tsx: boolean; | ||
decorators: boolean; | ||
/// `.d.ts` | ||
dts: boolean; | ||
noEarlyErrors: boolean; | ||
}; | ||
}; | ||
}; | ||
// Specify which modules to be bundled tother | ||
partialBundling?: { | ||
moduleBuckets?: { | ||
name: string; | ||
test: string[]; | ||
}[]; | ||
}; | ||
// Enable lazyCompilation or not | ||
lazyCompilation?: boolean; | ||
}; | ||
``` | ||
|
||
## Server Options | ||
|
||
```ts | ||
export default defineFarmConfig({ | ||
// Options related compilation | ||
server: ServerOptions; | ||
// .. | ||
}); | ||
|
||
interface ServerOptions { | ||
https?: boolean; | ||
port?: number; | ||
hmr?: boolean; | ||
} | ||
``` | ||
|
||
## Plugins Options | ||
|
||
```ts | ||
export default defineFarmConfig({ | ||
// Options related compilation | ||
plugins: (RustPlugin | JsPlugin)[]; | ||
// .. | ||
}); | ||
|
||
export type RustPlugin = | ||
| string | ||
| [ | ||
string, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Record<string, any> | ||
]; | ||
|
||
export interface JsPlugin { | ||
resolve: JsPluginHook< | ||
{ | ||
importers: string[]; | ||
specifiers: string[]; | ||
}, | ||
PluginResolveHookParam, | ||
PluginResolveHookResult | ||
>; | ||
|
||
// load: JsPluginHook<{ filters: { ids: string[] }}>; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Features", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Features supported by Farm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Css | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Html | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Lazy Compilation | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Partial Bundling | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# Js/Jsx/Ts/Tsx | ||
WIP... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Static Assets | ||
WIP... |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Performance Compare | ||
|
||
For a basic React demo project: | ||
|
||
| | Webpack | Vite | Farm | Compare | | ||
| ------------------- | ------- | ----- | ----- | --------------------------------------------- | | ||
| **cold start** | 853ms | 276ms | 67ms | Farm is faster: **12x webpack**,**4x vite** | | ||
| **HMR** | 43ms | 23ms | 2ms | Farm is faster: **20x webpack**,**10x vite** | | ||
| **onload** | 83ms | 310ms | 57ms | Farm is faster: **5x vite** | | ||
| **accessible time** | 936ms | 586ms | 124ms | Farm is faster: **8x webpack**,**5x vite** | | ||
|
||
> Test Repo:https://github.com/farm-fe/performance-compare | ||
> | ||
> Test Machine(Linux Mint 21.1 Cinnamon, 11th Gen Intel© Core™ i5-11400 @ 2.60GHz × 6, 15.5 GiB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Js Plugins | ||
This doc is under construction... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# Overview | ||
This doc is under construction... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# Rust Plugins | ||
This doc is under construction... |
Oops, something went wrong.