threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

rollup.config.mjs 3.0KB

2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 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",
  21. "threepipe": "threepipe",
  22. "@threepipe/plugin-tweakpane": "@threepipe/plugin-tweakpane" // would be used in externals
  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. preventAssignment: true,
  63. }),
  64. replace({
  65. 'process.env.NODE_ENV': JSON.stringify('production'),
  66. preventAssignment: true,
  67. }),
  68. postcss({
  69. modules: false,
  70. autoModules: true, // todo; issues with typescript import css, because inject is false
  71. inject: false,
  72. minimize: isProduction,
  73. // Or with custom options for `postcss-modules`
  74. }),
  75. json(),
  76. resolve({}),
  77. typescript({
  78. }),
  79. commonjs({
  80. include: 'node_modules/**',
  81. extensions: ['.js'],
  82. ignoreGlobal: false,
  83. sourceMap: false
  84. }),
  85. license({
  86. banner: `
  87. @license
  88. ${name} v${version}
  89. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  90. ${packageJson.license} License
  91. See ./dependencies.txt for any bundled third-party dependencies and licenses.
  92. `,
  93. thirdParty: {
  94. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  95. includePrivate: true, // Default is false.
  96. },
  97. })
  98. ]
  99. }