build.mjs 858 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env node
  2. import {
  3. buildJsIcons,
  4. buildIconsList,
  5. buildIconsDynamicImport,
  6. } from '../../.build/build-icons.mjs';
  7. const componentTemplate = ({ type, name, namePascal, children }) => `\
  8. import createReactComponent from '../createReactComponent';
  9. export default createReactComponent('${type}', '${name}', '${namePascal}', ${JSON.stringify(children)});`;
  10. const indexItemTemplate = ({ name, namePascal }) =>
  11. `export { default as ${namePascal} } from './${namePascal}';`;
  12. const aliasTemplate = ({ fromPascal, toPascal }) =>
  13. `export { default as Icon${fromPascal} } from './icons/Icon${toPascal}';\n`;
  14. buildJsIcons({
  15. name: 'icons-react',
  16. componentTemplate,
  17. indexItemTemplate,
  18. aliasTemplate,
  19. indexFile: 'index.ts',
  20. pascalCase: true,
  21. extension: 'ts',
  22. });
  23. buildIconsList('icons-react');
  24. buildIconsDynamicImport('icons-react');