diff --git a/README.md b/README.md index 96a66233..65c692fc 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,27 @@ npm i svgtofont "scripts": { "font": "svgtofont --sources ./svg --output ./font --fontName uiw-font" }, + "svgtofont": { + "css": { + "fontSize": "12px" + } + } } ``` You can add configuration to package.json. [#48](https://github.com/jaywcjlove/svgtofont/issues/48) +Supports `.svgtofontc` Configuration File. + +```js +{ + "src": "./icon", + "dist": "./fonts", + "fontName": "svgtofont", + "css": true +} +``` + #### Using With Nodejs ```js diff --git a/src/index.ts b/src/index.ts index 22579446..4d28a5b1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -163,6 +163,14 @@ export default async (options: SvgToFontOptions = {}) => { } } + const confPath = path.join(process.cwd(), '.svgtofontrc'); + if (fs.pathExistsSync(confPath)) { + const pkg = require(confPath); + if (pkg.svgtofont) { + options = { ...options, ...pkg.svgtofont } + } + } + options.dist = options.dist || path.join(process.cwd(), 'fonts'); options.src = options.src || path.join(process.cwd(), 'svg'); options.startUnicode = options.startUnicode || 0xea01;