Skip to content

Commit b53fa56

Browse files
author
Jordan Gensler
committed
Adding ignorePattern to allow selectively disabling the plugin
1 parent 659fe80 commit b53fa56

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ const buildSvg = template(`
1010
var SVG_NAME = function SVG_NAME(props) { return SVG_CODE; };
1111
`);
1212

13+
let ignoreRegex;
14+
1315
export default ({ types: t }) => ({
1416
visitor: {
1517
ImportDeclaration(path, state) {
18+
const { ignorePattern } = state.opts;
19+
if (ignorePattern) {
20+
// Only set the ignoreRegex once:
21+
ignoreRegex = ignoreRegex || new RegExp(ignorePattern);
22+
// Test if we should ignore this:
23+
if (ignoreRegex.test(path.node.source.value)) {
24+
return;
25+
}
26+
}
1627
// This plugin only applies for SVGs:
1728
if (extname(path.node.source.value) === '.svg') {
1829
// We only support the import default specifier, so let's use that identifier:

0 commit comments

Comments
 (0)