-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
Custom template breaking in @svgr/webpack #128
Comments
Yes templates changed! You can take inspiration from the default template, sorry! |
Any ideas on how to get this working? This is compiling without errors but the template still isn't applying. I moved the
|
Try exporting the template directly?
|
Can we please reopen this issue? This is still a problem with the latest version (6.2.1), where I cannot specify custom imports. Neither this: loader: '@svgr/webpack',
options: {
ref: true,
memo: true,
babel: false, // I don't want my babel.config.js overwritten since it has better support for old browsers
jsxRuntime: 'automatic', // React >= v17 doesn't need `import React from 'react'`
exportType: 'named', // Try to force the React component to be exported via named `ReactComponent`
// ...
template(componentInfo, svgrConfig) {
const astBuilder = babelTemplateBuilder`
${componentInfo.imports};
${componentInfo.interfaces};
const ${componentInfo.componentName} = (${componentInfo.props}) => (
${componentInfo.jsx}
);
export default const FileUrl = '${svgrConfig.options.state.filePath}';
${componentInfo.exports};
`;
return astBuilder;
},
} Nor this: loader: '@svgr/webpack',
options: {
template(componentInfo, svgrConfig) {
componentInfo.exports?.push(babelTemplateBuilder`
const FileUrl = '${svgrConfig.options.state.filePath}';
export { FileUrl as default };
`);
const astBuilder = babelTemplateBuilder`
${componentInfo.imports};
${componentInfo.interfaces};
const ${componentInfo.componentName} = (${componentInfo.props}) => (
${componentInfo.jsx}
);
${componentInfo.exports};
`;
return astBuilder;
},
} Nor even this: loader: '@svgr/webpack',
options: {
template(componentInfo, svgrConfig) {
componentInfo.exports?.push(babelTemplateBuilder`
export default const FileUrl = '${svgrConfig.options.state.filePath}';
`);
// const astBuilder = babelTemplateBuilder(template);
const astBuilder = babelTemplateBuilder`
${componentInfo.imports};
${componentInfo.interfaces};
const ${componentInfo.componentName} = (${componentInfo.props}) => (
${componentInfo.jsx}
);
${componentInfo.exports};
export default const FileUrl = '${svgrConfig.options.state.filePath}';
`;
return astBuilder;
},
} Will work in order to get (what should obviously be the default behavior of) fixing v6's behavior to match that of the original, correct, v5 behavior of How would one do this? |
Hi there, we're having some issues upgrading to
2.0.0
, particularly with our custom template that worked great in1.10.0
. I'm eager to update and get this working again.This is our template file that used to work to extend our base Icon component.
Current Behavior: Renders plain SVG, without any of the template or props getting applied.
Expected behavior: Rendered SVG is wrapped inside our
Icon
markup with props and classnames applied.Does 2.0.0 make any API changes to the template? I'm struggling to find documentation or examples to follow if so. Thanks for your time!
The text was updated successfully, but these errors were encountered: