cli: bump webpack and rollup svgr plugins

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-17 00:58:18 +01:00
parent 561ee4746e
commit 1fc0cd3896
4 changed files with 76 additions and 253 deletions
+6 -11
View File
@@ -20,28 +20,23 @@
* them with .icon.svg
*/
export function svgrTemplate(
{ template }: any,
_opts: any,
{ imports, interfaces, componentName, jsx }: any,
{ imports, interfaces, componentName, props, jsx }: any,
{ tpl }: any,
) {
const iconName = {
...componentName,
name: `${componentName.name.replace(/icon$/, '')}Icon`,
};
const name = `${componentName.replace(/icon$/, '')}Icon`;
const defaultExport = {
type: 'ExportDefaultDeclaration',
declaration: iconName,
declaration: { type: 'Identifier', name },
};
const typeScriptTemplate = template.smart({ plugins: ['typescript'] });
return typeScriptTemplate.ast`
return tpl`
${imports}
import SvgIcon from '@material-ui/core/SvgIcon';
${interfaces}
const ${iconName} = props => React.createElement(SvgIcon, props, ${jsx.children});
const ${name} = (${props}) => React.createElement(SvgIcon, ${props}, ${jsx.children});
${defaultExport}`;
}