Skip to content

Commit

Permalink
feat: prefer .fatherrc.js (#3)
Browse files Browse the repository at this point in the history
feat: prefer .fatherrc.js
  • Loading branch information
sorrycc authored May 31, 2019
2 parents f75023c + e96662c commit e650cad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ $ father doc deploy

注:

1. 不能传 `--config` 参数,通过 `--config` 指定的文件内容可全部配置在 `.umirc.library.js`[doc](#doc) 配置里。
1. 不能传 `--config` 参数,通过 `--config` 指定的文件内容可全部配置在 `.fatherrc.js`[doc](#doc) 配置里。
2. 使用 `deploy` 之前请先执行 `build` 命令,文档部署后域名为:`https://yourname.github.io/your-repo`

## Config

新建 `.umirc.library.js` 文件进行配置。
新建 `.fatherrc.js` 文件进行配置。

比如:

Expand All @@ -100,7 +100,7 @@ export default {

注意:

1. lerna 项目可以为每个 package 单独配,并且可以继承根目录的 `.umirc.library.js` 配置
1. lerna 项目可以为每个 package 单独配,并且可以继承根目录的 `.fatherrc.js` 配置
2. 配置文件支持 es6 和 TypeScript

### Options
Expand Down
12 changes: 10 additions & 2 deletions src/getUserConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { existsSync } from 'fs';
import AJV from 'ajv';
import slash from 'slash2';
import { relative } from 'path';
import signale from 'signale';
import schema from './schema';
import { getExistFile } from './utils';
import { IBundleOptions } from './types';
Expand All @@ -11,6 +11,10 @@ function testDefault(obj) {
}

export const CONFIG_FILES = [
'.fatherrc.js',
'.fatherrc.jsx',
'.fatherrc.ts',
'.fatherrc.tsx',
'.umirc.library.js',
'.umirc.library.jsx',
'.umirc.library.ts',
Expand All @@ -24,7 +28,11 @@ export default function({ cwd }): IBundleOptions {
returnRelative: false,
});

if (existsSync(configFile)) {
if (configFile) {
if (configFile.includes('.umirc.library.')) {
signale.warn(`Please use .fatherrc.js instead of .umirc.library.js`);
}

const userConfig = testDefault(require(configFile)); // eslint-disable-line
const ajv = new AJV({ allErrors: true });
const isValid = ajv.validate(schema, userConfig);
Expand Down

0 comments on commit e650cad

Please sign in to comment.