Skip to content

Commit

Permalink
feat: add console warning about config file priority (#346)
Browse files Browse the repository at this point in the history
close #345
  • Loading branch information
paranoidjk authored and sorrycc committed Aug 1, 2017
1 parent 37eb213 commit 6b84486
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ extraPostCSSPlugins: [

### svgSpriteLoaderDirs

Notice:
- roadhog 版本必须 >= `0.6.0-beta1`
- 因为 `.roadhogrc` 配置文件优先级大于 `.roadhogrc.js`, 请先删除 `.roadhogrc`

配置一个路径数组, 该路径下的 svg 文件会全部交给 [svg-sprite-loader](https://github.com/kisenka/svg-sprite-loader) 处理

比如,使用 antd-mobile 的 [自定义 svg icon](https://mobile.ant.design/components/icon) 功能的用户,可以在 `.roadhogrc.js` 文件中做如下配置
Expand Down
5 changes: 4 additions & 1 deletion src/utils/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ function getConfig(configFile, paths) {
const jsConfig = paths.resolveApp(`${configFile}.js`);

if (existsSync(rcConfig)) {
return parseJSON(stripJsonComments(readFileSync(rcConfig, 'utf-8')), './roadhogrc');
if (process.env.NODE_ENV === 'development' && existsSync(jsConfig)) {
console.error(`Config error: You must delete ${rcConfig} if you want to use ${jsConfig}`);
}
return parseJSON(stripJsonComments(readFileSync(rcConfig, 'utf-8')), configFile);
} else if (existsSync(jsConfig)) {
return require(jsConfig); // eslint-disable-line
} else {
Expand Down

0 comments on commit 6b84486

Please sign in to comment.