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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. },
  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. plugins: [
  43. isProduction && terser()
  44. ]
  45. },
  46. {
  47. file: './dist/index.js',
  48. ...settings,
  49. name: name,
  50. format: 'umd',
  51. plugins: [
  52. isProduction && terser()
  53. ]
  54. }
  55. ],
  56. external: Object.keys(settings.globals),
  57. plugins: [
  58. replace({
  59. 'from \'three\'': 'from \'threepipe\'',
  60. delimiters: ['', ''],
  61. }),
  62. replace({
  63. 'process.env.NODE_ENV': JSON.stringify('production'),
  64. }),
  65. postcss({
  66. modules: false,
  67. autoModules: true, // todo; issues with typescript import css, because inject is false
  68. inject: false,
  69. minimize: isProduction,
  70. // Or with custom options for `postcss-modules`
  71. }),
  72. json(),
  73. resolve({}),
  74. typescript({
  75. }),
  76. commonjs({
  77. include: 'node_modules/**',
  78. extensions: ['.js'],
  79. ignoreGlobal: false,
  80. sourceMap: false
  81. }),
  82. license({
  83. banner: `
  84. @license
  85. ${name} v${version}
  86. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  87. ${packageJson.license} License
  88. See ./dependencies.txt for bundled third-party dependencies and licenses.
  89. `,
  90. thirdParty: {
  91. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  92. includePrivate: true, // Default is false.
  93. },
  94. })
  95. ]
  96. }