🚀 Feature Proposal
Keep it consistent and use the Svg prefix globally for:
- the file name, e.g.
smiley.svg -> SvgSmiley.jsx
- the component name, e.g.
SvgSmiley() (already implemented)
- the
index.js exports, e.g. instead of export { default as Smiley } from './Smiley';, do export { default as SvgSmiley } from './Smiley';
Motivation
Regarding #190, all Component names should be prefixed with Svg.
#383 mentions that the index.jsonly exports with Svg prefix if the component name starts with a number.
I know that it is possible to alias an import, but it's confusing for a new user to understand when/or when not the prefix is used.
End-users of this tool might have to run additional processing. First, after many trials and errors have I noticed the inconsistency.
Monkey Patch
Currently, I have to use a custom index template, e.g.
// svgr.config.js
const path = require('path');
/**
* Custom index.js template
*/
function defaultIndexTemplate(filePaths) {
const exportEntries = filePaths.map((filePath) => {
const basename = path.basename(filePath, path.extname(filePath));
const exportName = /^\d/.test(basename) ? `Svg${basename}` : basename;
return `export { default as Svg${exportName} } from './${basename}'`;
});
return exportEntries.join('\n');
}
module.exports = {
indexTemplate: defaultIndexTemplate,
};
and run a command to rename all generated component files with an Svg prefix.
🚀 Feature Proposal
Keep it consistent and use the
Svgprefix globally for:smiley.svg->SvgSmiley.jsxSvgSmiley()(already implemented)index.jsexports, e.g. instead ofexport { default as Smiley } from './Smiley';, doexport { default as SvgSmiley } from './Smiley';Motivation
Regarding #190, all Component names should be prefixed with
Svg.#383 mentions that the
index.jsonly exports withSvgprefix if the component name starts with a number.I know that it is possible to alias an import, but it's confusing for a new user to understand when/or when not the prefix is used.
End-users of this tool might have to run additional processing. First, after many trials and errors have I noticed the inconsistency.
Monkey Patch
Currently, I have to use a custom index template, e.g.
and run a command to rename all generated component files with an
Svgprefix.