threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rollup.config.mjs 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // rollup.config.js
  2. import commonjs from '@rollup/plugin-commonjs';
  3. import json from '@rollup/plugin-json';
  4. import resolve from '@rollup/plugin-node-resolve';
  5. import typescript from '@rollup/plugin-typescript';
  6. import license from 'rollup-plugin-license'
  7. import packageJson from './package.json' assert {type: 'json'};
  8. import path from 'path'
  9. import {fileURLToPath} from 'url';
  10. import terser from "@rollup/plugin-terser";
  11. import postcss from 'rollup-plugin-postcss'
  12. const __filename = fileURLToPath(import.meta.url);
  13. const __dirname = path.dirname(__filename);
  14. const {name, version, author} = packageJson
  15. const {main, module, browser} = packageJson["clean-package"].replace
  16. const isProduction = process.env.NODE_ENV === 'production'
  17. const settings = {
  18. globals: {},
  19. sourcemap: true
  20. }
  21. export default {
  22. input: './src/index.ts',
  23. output: [
  24. // {
  25. // file: main,
  26. // name: main,
  27. // ...settings,
  28. // format: 'cjs',
  29. // plugins: [
  30. // isProduction && terser()
  31. // ]
  32. // },
  33. {
  34. file: module,
  35. ...settings,
  36. name: name,
  37. // dir: 'dist', // indicate not create a single-file
  38. // preserveModules: true, // indicate not create a single-file
  39. // preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure
  40. format: 'es'
  41. },
  42. {
  43. file: browser,
  44. ...settings,
  45. name: name,
  46. format: 'umd',
  47. plugins: [
  48. isProduction && terser()
  49. ]
  50. }
  51. ],
  52. external: [],
  53. plugins: [
  54. postcss({
  55. modules: false,
  56. autoModules: true, // todo; issues with typescript import css, because inject is false
  57. inject: false,
  58. minimize: isProduction,
  59. // Or with custom options for `postcss-modules`
  60. }),
  61. json(),
  62. resolve({}),
  63. typescript({}),
  64. commonjs({
  65. include: 'node_modules/**',
  66. extensions: ['.js'],
  67. ignoreGlobal: false,
  68. sourceMap: false
  69. }),
  70. license({
  71. banner: `
  72. @license
  73. ${name} v${version}
  74. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  75. ${packageJson.license} License
  76. `,
  77. thirdParty: {
  78. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  79. includePrivate: true, // Default is false.
  80. },
  81. })
  82. ]
  83. }