threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

rollup.config.mjs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. "three": "threepipe",
  21. "threepipe": "threepipe"
  22. },
  23. sourcemap: true
  24. }
  25. export default {
  26. input: './src/index.ts',
  27. output: [
  28. // {
  29. // file: main,
  30. // name: main,
  31. // ...settings,
  32. // format: 'cjs',
  33. // plugins: [
  34. // isProduction && terser()
  35. // ]
  36. // },
  37. {
  38. file: './dist/index.mjs',
  39. ...settings,
  40. name: name,
  41. format: 'es',
  42. inlineDynamicImports: true,
  43. plugins: [
  44. isProduction && terser()
  45. ]
  46. },
  47. {
  48. file: './dist/index.js',
  49. ...settings,
  50. name: name,
  51. format: 'umd',
  52. inlineDynamicImports: true,
  53. plugins: [
  54. isProduction && terser()
  55. ]
  56. }
  57. ],
  58. external: Object.keys(settings.globals),
  59. plugins: [
  60. replace({
  61. 'from \'three\'': 'from \'threepipe\'',
  62. delimiters: ['', ''],
  63. preventAssignment: true,
  64. }),
  65. replace({
  66. 'process.env.NODE_ENV': JSON.stringify('production'),
  67. preventAssignment: true,
  68. }),
  69. postcss({
  70. modules: false,
  71. autoModules: true, // todo; issues with typescript import css, because inject is false
  72. inject: false,
  73. minimize: isProduction,
  74. // Or with custom options for `postcss-modules`
  75. }),
  76. json(),
  77. resolve({}),
  78. typescript({
  79. tsconfig: './tsconfig.json',
  80. }),
  81. commonjs({
  82. include: 'node_modules/**',
  83. extensions: ['.js'],
  84. ignoreGlobal: false,
  85. sourceMap: false
  86. }),
  87. license({
  88. banner: `
  89. @license
  90. ${name} v${version}
  91. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  92. ${packageJson.license} License
  93. See ./dependencies.txt for any bundled third-party dependencies and licenses.
  94. `,
  95. thirdParty: {
  96. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  97. includePrivate: true, // Default is false.
  98. },
  99. })
  100. ]
  101. }