Skip to content

Commit

Permalink
Merge pull request #15 from tkh44/10-optimization-disable-option
Browse files Browse the repository at this point in the history
Add option to disable optimization.
  • Loading branch information
kesne committed Jun 28, 2017
2 parents c5de3ee + 6b6181f commit ca9ca20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit ca9ca20

Please sign in to comment.