rollup.config.mjs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-react-native';
  6. const outputFileName = 'tabler-icons-react-native';
  7. const outputDir = 'dist';
  8. const inputs = ['./src/tabler-icons-react-native.ts'];
  9. const bundles = [
  10. {
  11. format: 'cjs',
  12. inputs,
  13. outputDir,
  14. },
  15. {
  16. format: 'esm',
  17. inputs,
  18. outputDir,
  19. preserveModules: true,
  20. },
  21. ];
  22. const configs = bundles
  23. .map(({ inputs, outputDir, format, minify, preserveModules }) =>
  24. inputs.map(input => ({
  25. input,
  26. plugins: getRollupPlugins(pkg, minify),
  27. external: ['react', 'react-native-svg'],
  28. output: {
  29. name: packageName,
  30. ...(preserveModules
  31. ? {
  32. dir: `${outputDir}/${format}`,
  33. }
  34. : {
  35. file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
  36. }),
  37. format,
  38. sourcemap: true,
  39. preserveModules,
  40. globals: {
  41. react: 'react',
  42. 'react-native-svg': 'react-native-svg',
  43. },
  44. },
  45. })),
  46. )
  47. .flat();
  48. export default [
  49. {
  50. input: inputs[0],
  51. output: [{
  52. file: `dist/${outputFileName}.d.ts`, format: "es"
  53. }],
  54. plugins: [dts()],
  55. },
  56. ...configs
  57. ];