diff --git a/README.md b/README.md index a1c468b..732d6fc 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ npm install --save-dev babel-plugin-inline-react-svg #### Options - *`ignorePattern`* - A pattern that imports will be tested against to selectively ignore imports. -- *`svgo`* - svgo options. Example: +- *`svgo`* - svgo options (`false` to disable). Example: ```json { "plugins": [ diff --git a/src/index.js b/src/index.js index 3fef0a1..bd61411 100644 --- a/src/index.js +++ b/src/index.js @@ -32,9 +32,12 @@ export default ({ types: t }) => ({ const importIdentifier = path.node.specifiers[0].local; const iconPath = state.file.opts.filename; const svgPath = resolveFrom(dirname(iconPath), path.node.source.value); - const svgSource = readFileSync(svgPath, 'utf8'); - const optimizedSvgSource = optimize(svgSource, state.opts.svgo); - const escapeSvgSource = escapeBraces(optimizedSvgSource); + const rawSource = readFileSync(svgPath, 'utf8'); + const optimizedSource = state.opts.svgo === false + ? rawSource + : optimize(rawSource, state.opts.svgo); + + const escapeSvgSource = escapeBraces(optimizedSource); const parsedSvgAst = parse(escapeSvgSource, { sourceType: 'module',