threepipe
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

rollup.config.mjs 3.0KB

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