rollup.config.mjs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import path from 'node:path'
  2. import process from 'node:process'
  3. import { fileURLToPath } from 'node:url'
  4. import { babel } from '@rollup/plugin-babel'
  5. import { nodeResolve } from '@rollup/plugin-node-resolve'
  6. import replace from '@rollup/plugin-replace'
  7. import banner from '@repo/banner'
  8. const __dirname = path.dirname(fileURLToPath(import.meta.url))
  9. const ESM = process.env.ESM === 'true'
  10. let destinationFile = `tabler${ESM ? '.esm' : ''}`
  11. const external = []
  12. const plugins = [
  13. babel({
  14. exclude: 'node_modules/**',
  15. babelHelpers: 'bundled'
  16. })
  17. ]
  18. plugins.push(
  19. replace({
  20. 'process.env.NODE_ENV': '"production"',
  21. preventAssignment: true
  22. }),
  23. nodeResolve()
  24. )
  25. const rollupConfig = {
  26. input: path.resolve(__dirname, `../js/tabler.${ESM ? 'esm' : 'umd'}.js`),
  27. output: {
  28. banner: banner(),
  29. file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`),
  30. format: ESM ? 'esm' : 'umd',
  31. generatedCode: 'es2015'
  32. },
  33. external,
  34. plugins
  35. }
  36. if (!ESM) {
  37. rollupConfig.output.name = 'tabler'
  38. }
  39. export default rollupConfig