rollup.config.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import css from 'rollup-plugin-css-only'
  2. import del from 'rollup-plugin-delete'
  3. import dts from 'rollup-plugin-dts'
  4. import { typescriptPaths } from 'rollup-plugin-typescript-paths'
  5. import typescript from '@rollup/plugin-typescript'
  6. import terser from '@rollup/plugin-terser'
  7. import pkg from './package.json' assert { type: 'json' }
  8. const banner = `/**
  9. * Vue 3 Carousel ${pkg.version}
  10. * (c) ${new Date().getFullYear()}
  11. * @license MIT
  12. */`
  13. export default [
  14. {
  15. input: 'src/index.ts',
  16. output: [
  17. // UMD output
  18. {
  19. file: pkg.main,
  20. format: 'umd',
  21. name: 'VueCarousel',
  22. banner,
  23. globals: {
  24. vue: 'Vue',
  25. },
  26. },
  27. // ES output
  28. {
  29. file: pkg.module,
  30. format: 'es',
  31. banner,
  32. },
  33. // Minified UMD output
  34. {
  35. file: 'dist/carousel.min.js',
  36. format: 'umd',
  37. name: 'VueCarousel',
  38. banner,
  39. globals: {
  40. vue: 'Vue',
  41. },
  42. plugins: [terser()],
  43. },
  44. // Minified ES output
  45. {
  46. file: 'dist/carousel.es.min.js',
  47. format: 'es',
  48. banner,
  49. plugins: [terser()],
  50. },
  51. ],
  52. external: [
  53. ...Object.keys(pkg.dependencies || {}),
  54. ...Object.keys(pkg.peerDependencies || {}),
  55. ],
  56. plugins: [
  57. css({ output: 'carousel.css' }),
  58. typescript(),
  59. del({ targets: 'dist/*', hook: 'buildStart' }), // Clean 'dist' folder before each build
  60. ],
  61. },
  62. {
  63. input: 'dist/index.d.ts',
  64. output: [{ file: 'dist/carousel.d.ts', format: 'es' }],
  65. external: [/\.css$/],
  66. plugins: [
  67. typescriptPaths({ preserveExtensions: true }),
  68. dts(),
  69. del({ hook: 'buildEnd', targets: ['dist/**', '!dist/carousel.*'], runOnce: true }),
  70. ],
  71. },
  72. ]