Skip to content

Commit

Permalink
feat:update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryYuX committed Oct 29, 2021
1 parent 8a53452 commit f9385bf
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/docs/tutorial-basics/插件配置.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sidebar_position: 10
本框架插件机制完全继承 Vite 插件体系,插件使用方式通 Vite 保持一致。例如:

```js
// vite.config.js
// viter.config.ts
import legacy from '@vitejs/plugin-legacy';
import { defineConfig } from 'viter';

Expand Down
18 changes: 16 additions & 2 deletions docs/docs/tutorial-basics/构建配置.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ sidebar_position: 11

# 构建配置

Viter 构建配置在 [Vite 构建配置](https://cn.vitejs.dev/config/#build-options)的基础上,追加了如下配置:
Viter 构建配置在 [Vite 构建配置](https://cn.vitejs.dev/config/#build-options) 的基础上,追加了如下配置:

### runtimePublicPath

用于启用运行时的 publicPath ,详见运行时配置章节。

### BuildMode
### buildMode

- Type: `'single' | 'split' | 'split-js'`

Expand All @@ -31,3 +31,17 @@ Viter 构建配置在 [Vite 构建配置](https://cn.vitejs.dev/config/#build-op
- split-js

该模式关闭 css split,其余和 split 模式相同。

构建相关配置示例如下:

```js
// viter.config.ts
import { defineConfig } from 'viter';

export default defineConfig({
build: {
runtimePublicPath: { preloadBaseMarker: 'window.publicPath' },
buildMode: 'single',
},
});
```
4 changes: 3 additions & 1 deletion docs/docs/tutorial-basics/路由.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 8

# 路由

目前 Viter 暂时只支持单页应用(spa)场景。在该场景下,页面跳转都在浏览器端完成,由路由进行控制。
目前 Viter 暂时只支持单页应用(spa)场景。在该场景下,页面跳转都在浏览器端完成,由路由进行控制。Viter 路由部分基于最新的 `react-router@6`, 相比于旧版本的路由,跳转和参数获取方式有所差异,具体可参考文档[《Migrating React Router v5 to v6》](https://github.com/remix-run/react-router/blob/main/docs/guides/migrating-5-to-6.md)

## 配置路由

Expand Down Expand Up @@ -106,6 +106,8 @@ function xxx() {
}
```

### class 组件兼容

对于 class 组件,viter 提供高阶组件 withRouter,你可以用 withRouter 中注入的 history 来进行跳转。该方法主要用作兼容 class 组件和 react-router@5 部分写法,但我们强烈建议在增量的项目中使用 hooks 写法。

```js
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial-extras/后端集成.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sidebar_position: 2
1. 在你的 Viter 配置中配置入口文件和启用创建 `manifest`

```js
// viter.config.js
// viter.config.ts
export default defineConfig({
build: {
// 在 outDir 中生成 manifest.json
Expand Down
6 changes: 2 additions & 4 deletions packages/create-app/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# `create-vite-app`
# `create-viter-app`

> TODO: description
## Usage

```js
const createViteApp = require('icva');

// TODO: DEMONSTRATE API
npm init @viterjs/app
```
4 changes: 4 additions & 0 deletions packages/create-app/template-react-admin-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `Viter`

Viter 是一款基于 Vite 的前端框架,目前主要服务与中后台开发者,其本质上是 Vite 的上层框架,扩展了路由等模块,让 Vite 技术能够更加便捷的在项目中得到应用。
[进入官方文档](https://viterjs.github.io/)
2 changes: 1 addition & 1 deletion packages/create-app/template-react-admin-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react-refresh": "^1.3.1",
"@vitejs/plugin-react": "^1.0.1",
"typescript": "^4.1.2"
}
}
4 changes: 2 additions & 2 deletions packages/create-app/template-react-admin-ts/viter.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from 'viter';
import reactRefresh from '@vitejs/plugin-react-refresh';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [reactRefresh()],
plugins: [react()],
routes: [
{
path: '/',
Expand Down

0 comments on commit f9385bf

Please sign in to comment.