Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG import error using react-template #65

Open
sombrilla opened this issue May 30, 2022 · 2 comments
Open

SVG import error using react-template #65

sombrilla opened this issue May 30, 2022 · 2 comments

Comments

@sombrilla
Copy link

While using react-template, importing SVG throws an error:

Syntax Error: Error: Plugin name should be specified at Array.map (<anonymous>)

Version:
"@pota/react-webpack-scripts": "~1.0.3"

Here is the diff that solved my problem:

diff --git a/node_modules/@pota/react-webpack-scripts/lib/config.js b/node_modules/@pota/react-webpack-scripts/lib/config.js
index 0c9c06b..7dbc969 100644
--- a/node_modules/@pota/react-webpack-scripts/lib/config.js
+++ b/node_modules/@pota/react-webpack-scripts/lib/config.js
@@ -49,14 +49,22 @@ export class ReactWebpackConfig extends WebpackConfig {
                     options: {
                         prettier: false,
                         svgoConfig: {
-                            plugins: [{ removeViewBox: false }],
+                            plugins: [ {
+                                name: 'preset-default',
+                                params: {
+                                    overrides: {
+                                        removeViewBox: false,
+                                    },
+                                },
+                            }],
                         },
                         titleProp: true,
                         ref: true,
                     },
                 },
-                { loader: 'url-loader' },
             ],
+            issuer: /\.[jt]sx?$/,
+            resourceQuery: { not: [/url/] },
         };
     }
 }
@skriptiko
Copy link

same issue

@ThaNarie
Copy link
Member

@sombrilla Were the issuer and resourceQuery also needed to fix this?
If so, could you explain?

The original issue looks like a breaking change that required a different config, so that looks good. But the other changes seem unrelated to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants