rollup.config.js 690 B

123456789101112131415161718192021222324252627282930313233343536
  1. import dts from "rollup-plugin-dts"
  2. import esbuild from "rollup-plugin-esbuild"
  3. import multi from "@rollup/plugin-multi-entry"
  4. const name = require("./package.json").main.replace(/\.js$/, "")
  5. const bundle = (config) => ({
  6. ...config,
  7. input: "src/**/*.ts",
  8. external: (id) => !/^[./]/.test(id),
  9. })
  10. export default [
  11. bundle({
  12. plugins: [multi(), esbuild()],
  13. output: [
  14. {
  15. file: `${name}.js`,
  16. format: "cjs",
  17. sourcemap: true,
  18. },
  19. {
  20. file: `${name}.mjs`,
  21. format: "es",
  22. sourcemap: true,
  23. },
  24. ],
  25. }),
  26. bundle({
  27. plugins: [dts()],
  28. output: {
  29. file: `${name}.d.ts`,
  30. format: "es",
  31. },
  32. }),
  33. ]