build.mjs 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env node
  2. import { buildJsIcons } from '../../.build/build-icons.mjs'
  3. const componentTemplate = ({
  4. type,
  5. name,
  6. children,
  7. stringify
  8. }) => {
  9. return `\
  10. <script lang="ts">
  11. import Icon from '../Icon.svelte';
  12. import type { IconNode, IconProps } from '../types.js';
  13. type $$Props = IconProps;
  14. const iconNode: IconNode = ${JSON.stringify(children)};
  15. </script>
  16. <Icon type="${type}" name="${name}" {...$$props} iconNode={iconNode}>
  17. <slot/>
  18. </Icon>
  19. `;
  20. };
  21. const aliasTemplate = ({ fromPascal, to }) => `export { default as Icon${fromPascal} } from './icons/${to}.svelte';\n`
  22. const indexItemTemplate = ({
  23. name,
  24. namePascal
  25. }) => `export { default as ${namePascal} } from './${name}.svelte';`
  26. buildJsIcons({
  27. name: 'icons-svelte',
  28. componentTemplate,
  29. indexItemTemplate,
  30. aliasTemplate,
  31. extension: 'svelte',
  32. pretty: false,
  33. key: false,
  34. indexFile: 'index.ts',
  35. pascalName: false,
  36. })