Skip to content

Commit

Permalink
feat(config): add defineConfig (Lucifier129#32)
Browse files Browse the repository at this point in the history
* feat(config): add defineConfig

* docs: update defineConfig
  • Loading branch information
tqma113 authored Oct 29, 2021
1 parent acf3a36 commit 59067be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 7 additions & 8 deletions doc/Config/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

```ts
import path from 'path'
import { Config } from '../../src'
import cf from './config'
import { defineConfig } from 'react-imvc'

let PORT = 33336
const ROOT = __dirname

const config: Config = {
const config = defineConfig({
root: ROOT, // 项目根目录
port: PORT, // server 端口号
routes: 'routes', // 服务端路由目录
Expand All @@ -25,7 +24,7 @@ const config: Config = {
path: path.resolve(ROOT, '../publish/static')
},
webpackDevMiddleware: true
}
})

export default config
```
Expand All @@ -52,16 +51,16 @@ export default config
启动文件中需要使用 React-IMVC 中暴露的接口启动,使用方式如下:

```ts
import start from '../../src/start'
import { Config } from '../../src/'
import { start, defineConfig } from 'react-imvc'

const PORT: number = 3333
const ROOT = __dirname
const config: Config = {
const config = defineConfig({
root: ROOT, // 项目根目录
port: PORT, // server 端口号
routes: 'routes', // 服务端路由目录
layout: 'Layout', // 自定义 Layout
}
})

async function main() {
let { app, server } = await start({ config })
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,7 @@ export interface EntireConfig {
*/
entry?: string | string[] | webpack.Entry | webpack.EntryFunc
}

export const defineConfig = (config: Config): Config => {
return config
}

0 comments on commit 59067be

Please sign in to comment.