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.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. import replace from 'rollup-plugin-replace'
  13. const __filename = fileURLToPath(import.meta.url);
  14. const __dirname = path.dirname(__filename);
  15. const {name, version, author} = packageJson
  16. // const {main, module, browser} = packageJson["clean-package"].replace
  17. const isProduction = process.env.NODE_ENV === 'production'
  18. const settings = {
  19. globals: {
  20. "threepipe": "threepipe"
  21. },
  22. sourcemap: true
  23. }
  24. export default {
  25. input: './src/index.ts',
  26. output: [
  27. // {
  28. // file: main,
  29. // name: main,
  30. // ...settings,
  31. // format: 'cjs',
  32. // plugins: [
  33. // isProduction && terser()
  34. // ]
  35. // },
  36. {
  37. file: './dist/index.mjs',
  38. ...settings,
  39. name: name,
  40. format: 'es',
  41. plugins: [
  42. isProduction && terser()
  43. ]
  44. },
  45. {
  46. file: './dist/index.js',
  47. ...settings,
  48. name: name,
  49. format: 'umd',
  50. plugins: [
  51. isProduction && terser()
  52. ]
  53. }
  54. ],
  55. external: Object.keys(settings.globals),
  56. plugins: [
  57. replace({
  58. // If you would like DEV messages, specify 'development'
  59. // Otherwise use 'production'
  60. 'process.env.NODE_ENV': JSON.stringify('production') // for tippy.js
  61. }),
  62. postcss({
  63. modules: false,
  64. autoModules: true, // todo; issues with typescript import css, because inject is false
  65. inject: false,
  66. minimize: isProduction,
  67. // Or with custom options for `postcss-modules`
  68. }),
  69. json(),
  70. resolve({}),
  71. typescript({
  72. tsconfig: './tsconfig.json',
  73. }),
  74. commonjs({
  75. include: 'node_modules/**',
  76. extensions: ['.js'],
  77. ignoreGlobal: false,
  78. sourceMap: false
  79. }),
  80. license({
  81. banner: `
  82. @license
  83. ${name} v${version}
  84. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  85. ${packageJson.license} License
  86. `,
  87. thirdParty: {
  88. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  89. includePrivate: true, // Default is false.
  90. },
  91. })
  92. ]
  93. }