rollup.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import resolve from '@rollup/plugin-node-resolve';
  2. import commonjs from '@rollup/plugin-commonjs';
  3. import sourceMaps from 'rollup-plugin-sourcemaps';
  4. import typescript from '@rollup/plugin-typescript';
  5. import json from 'rollup-plugin-json';
  6. const pkg = require('./package.json');
  7. const banner = `/*
  8. * ${pkg.name} ${pkg.version} <${pkg.homepage}>
  9. * Copyright (c) ${(new Date()).getFullYear()} ${pkg.author.name} <${pkg.author.url}>
  10. * Released under ${pkg.license} License
  11. */`;
  12. export default {
  13. input: `src/index.ts`,
  14. output: [
  15. { file: pkg.main, name: pkg.name, format: 'umd', banner, sourcemap: true },
  16. { file: pkg.module, format: 'esm', banner, sourcemap: true },
  17. ],
  18. external: [],
  19. watch: {
  20. include: 'src/**',
  21. },
  22. plugins: [
  23. // Allow node_modules resolution, so you can use 'external' to control
  24. // which external modules to include in the bundle
  25. // https://github.com/rollup/rollup-plugin-node-resolve#usage
  26. resolve(),
  27. // Allow json resolution
  28. json(),
  29. // Compile TypeScript files
  30. typescript({ sourceMap: true, inlineSources: true }),
  31. // Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
  32. commonjs(),
  33. // Resolve source maps to the original source
  34. sourceMaps(),
  35. ],
  36. }