rollup.config.mjs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-vue';
  6. const outputFileName = 'tabler-icons-vue';
  7. const outputDir = 'dist';
  8. const inputs = ['./src/tabler-icons-vue.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: ['vue'],
  39. output: {
  40. name: packageName,
  41. ...(preserveModules
  42. ? {
  43. dir: `${outputDir}/${format}`,
  44. }
  45. : {
  46. file: `${outputDir}/${format}/${outputFileName}${minify ? '.min' : ''}.js`,
  47. }),
  48. format,
  49. preserveModules,
  50. sourcemap: true,
  51. globals: {
  52. vue: 'vue',
  53. },
  54. },
  55. })),
  56. )
  57. .flat();
  58. export default [
  59. {
  60. input: inputs[0],
  61. output: [{
  62. file: `dist/${outputFileName}.d.ts`, format: "es"
  63. }],
  64. plugins: [
  65. dts({
  66. compilerOptions: {
  67. preserveSymlinks: false
  68. }
  69. })
  70. ],
  71. },
  72. ...configs
  73. ];