Skip to content

Commit

Permalink
chore: setup quick start page (#2)
Browse files Browse the repository at this point in the history
* feat: add quick start and why farm, construct doc structure

* chore: adjust reame

* fix: build error
  • Loading branch information
wre232114 authored Mar 7, 2023
1 parent cc7f407 commit 285ef94
Show file tree
Hide file tree
Showing 45 changed files with 5,138 additions and 1,020 deletions.
45 changes: 9 additions & 36 deletions README.md
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.
2 changes: 2 additions & 0 deletions docs/config/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CLI Options
WIP...
156 changes: 156 additions & 0 deletions docs/config/farm-config.md
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[] }}>;
}
```
8 changes: 8 additions & 0 deletions docs/features/_category_.json
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"
}
}
2 changes: 2 additions & 0 deletions docs/features/css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Css
WIP...
6 changes: 6 additions & 0 deletions docs/features/html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 1
---

# Html
WIP...
2 changes: 2 additions & 0 deletions docs/features/lazy-compilation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Lazy Compilation
WIP...
2 changes: 2 additions & 0 deletions docs/features/partial-bundling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Partial Bundling
WIP...
3 changes: 3 additions & 0 deletions docs/features/script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Js/Jsx/Ts/Tsx
WIP...
2 changes: 2 additions & 0 deletions docs/features/static.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Static Assets
WIP...
47 changes: 0 additions & 47 deletions docs/intro.md

This file was deleted.

14 changes: 14 additions & 0 deletions docs/performance.md
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)
2 changes: 2 additions & 0 deletions docs/plugins/js-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Js Plugins
This doc is under construction...
3 changes: 3 additions & 0 deletions docs/plugins/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Overview
This doc is under construction...
3 changes: 3 additions & 0 deletions docs/plugins/rust-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Rust Plugins
This doc is under construction...
Loading

0 comments on commit 285ef94

Please sign in to comment.