rollup.config.mjs 1.4 KB

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