rollup.config.mjs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import fs from 'fs'
  2. import { getRollupPlugins } from '../../.build/build-icons.mjs'
  3. const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
  4. const packageName = '@tabler/icons-preact';
  5. const outputFileName = 'tabler-icons-preact';
  6. const outputDir = 'dist';
  7. const inputs = ['./src/tabler-icons-preact.js'];
  8. const bundles = [
  9. {
  10. format: 'umd',
  11. inputs,
  12. outputDir,
  13. minify: true,
  14. },
  15. {
  16. format: 'umd',
  17. inputs,
  18. outputDir,
  19. },
  20. {
  21. format: 'cjs',
  22. inputs,
  23. outputDir,
  24. },
  25. {
  26. format: 'es',
  27. inputs,
  28. outputDir,
  29. },
  30. {
  31. format: 'esm',
  32. inputs,
  33. outputDir,
  34. preserveModules: true,
  35. },
  36. ];
  37. const configs = bundles
  38. .map(({ inputs, outputDir, format, minify, preserveModules }) =>
  39. inputs.map(input => ({
  40. input,
  41. plugins: getRollupPlugins(pkg, minify),
  42. external: ['preact', 'prop-types'],
  43. output: {
  44. name: packageName,
  45. ...(preserveModules
  46. ? {
  47. dir: `${outputDir}/${format}`,
  48. }
  49. : {
  50. file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
  51. }),
  52. preserveModules,
  53. format,
  54. sourcemap: true,
  55. globals: {
  56. preact: 'preact',
  57. 'prop-types': 'PropTypes',
  58. },
  59. },
  60. })),
  61. )
  62. .flat();
  63. export default configs;