rollup.config.mjs 1.6 KB

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