Skip to content

Commit

Permalink
chore: docs for new feature (#6013)
Browse files Browse the repository at this point in the history
* chore: docs for new feature

* chore: package link
  • Loading branch information
ClarkXia authored Mar 6, 2023
1 parent c23c10e commit 4601c02
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"author": "ice-admin@alibaba-inc.com",
"license": "MIT",
"homepage": "https://v3.ice.work",
"repository": "ice-lab/ice-next",
"bugs": "https://github.com/ice-lab/ice-next/issues",
"repository": "alibaba/ice",
"bugs": "https://github.com/alibaba/ice/issues",
"scripts": {
"prepare": "husky install",
"setup": "rm -rf node_modules packages/*/node_modules && pnpm install && pnpm prebundle && pnpm build",
Expand Down
55 changes: 53 additions & 2 deletions website/docs/guide/basic/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ export default defineConfig(() => ({
小程序端不支持该配置。
:::

- 类型:`{ format: 'esm' | 'cjs'; bundle: boolean; ignores: IgnorePattern[]; externals: string[] }`
- 默认值:`{ format: 'esm', bundle: false, ignores: [], externals: [] }`
- 类型:`{ format: 'esm' | 'cjs'; bundle: boolean; ignores: IgnorePattern[]; externals: string[]; onDemand: boolean; }`
- 默认值:`{ format: 'esm', bundle: false, ignores: [], externals: [], onDemand: false }`

SSR / SSG 产物标准,推荐以 ESM 标准进行执行,如果希望打包成一个 cjs 模块,可以进行如下设置:

Expand Down Expand Up @@ -434,6 +434,19 @@ export default defineConfig(() => ({
}));
```

通过 `onDemand` 参数,可以在执行 Server 端产物时,按需构建所需的问题,并且提供体验良好的模块热更新服务:

```js
import { defineConfig } from '@ice/app';

export default defineConfig(() => ({
server: {
onDemand: true,
format: 'esm',
},
}));
```

### routes

:::caution
Expand Down Expand Up @@ -491,6 +504,44 @@ route('/about-you', 'about.tsx');
```
:::

#### config

对于简单的自定义场景,通过 `defineRoutes` 可以快速在约定式路由的基础上进行自定义。但对于大量自定义或者原配置式路由的升级项目,支持以 `config` 的字段指定路由信息:

```ts
import { defineConfig } from '@ice/app';

export default defineConfig({
routes: {
config: [
{
path: 'rewrite',
// 从 src/page 开始计算路径,并且需要写后缀。
component: 'sales/layout.tsx',
children: [
{
path: '/favorites',
component: 'sales/favorites.tsx',
},
{
path: 'overview',
component: 'sales/overview.tsx',
},
{
path: 'recommends',
component: 'sales/recommends.tsx',
},
],
},
{
path: '/',
component: 'index.tsx',
},
],
},
});
```

### sourceMap

- 类型:`boolean | string`
Expand Down

0 comments on commit 4601c02

Please sign in to comment.