Skip to content

Commit

Permalink
Add option to disable optimization. closes airbnb#10
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye Hohenberger committed Jun 21, 2017
1 parent c5de3ee commit cefa18b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let ignoreRegex;

export default ({ types: t }) => ({
visitor: {
ImportDeclaration(path, state) {
ImportDeclaration (path, state) {
const { ignorePattern } = state.opts;
if (ignorePattern) {
// Only set the ignoreRegex once:
Expand All @@ -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');
let optimizedSource = state.opts.svgo === false
? optimize(rawSource, state.opts.svgo)
: rawSource

const escapeSvgSource = escapeBraces(optimizedSource);

const parsedSvgAst = parse(escapeSvgSource, {
sourceType: 'module',
Expand Down

0 comments on commit cefa18b

Please sign in to comment.