rollup.config.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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';
  5. const outputFileName = 'tabler-icons';
  6. const outputDir = 'dist';
  7. const inputs = ['./src/tabler-icons.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. output: {
  43. name: packageName,
  44. ...(preserveModules
  45. ? {
  46. dir: `${outputDir}/${format}`,
  47. }
  48. : {
  49. file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
  50. }),
  51. format,
  52. preserveModules,
  53. sourcemap: true,
  54. },
  55. })),
  56. )
  57. .flat();
  58. export default configs;