threepipe
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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' assert {type: 'json'};
  8. import path from 'path'
  9. import {fileURLToPath} from 'url';
  10. import postcss from 'rollup-plugin-postcss'
  11. import glsl from "rollup-plugin-glsl"
  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. sourcemap: true
  21. }
  22. export default {
  23. input: './src/index.ts',
  24. output: [
  25. // {
  26. // file: main,
  27. // name: main,
  28. // ...settings,
  29. // format: 'cjs',
  30. // plugins: [
  31. // isProduction && terser()
  32. // ]
  33. // },
  34. {
  35. file: module,
  36. ...settings,
  37. name: name,
  38. // dir: 'dist', // indicate not create a single-file
  39. // preserveModules: true, // indicate not create a single-file
  40. // preserveModulesRoot: 'src', // optional but useful to create a more plain folder structure
  41. format: 'es'
  42. },
  43. // {
  44. // file: browser,
  45. // ...settings,
  46. // name: name,
  47. // format: 'umd',
  48. // plugins: [
  49. // isProduction && terser()
  50. // ]
  51. // }
  52. ],
  53. external: [],
  54. plugins: [
  55. replace({
  56. 'process.env.NODE_ENV': JSON.stringify( 'production' ),
  57. }),
  58. // replace({
  59. // exclude: 'src/**',
  60. // delimiters: ['', ''],
  61. // values:{
  62. // 'from \'three\'': 'from \'threepipe\'',
  63. // },
  64. // }),
  65. glsl({ // todo: minify glsl.
  66. include: "src/**/*.glsl"
  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. commonjs({
  79. include: 'node_modules/**',
  80. extensions: ['.js'],
  81. ignoreGlobal: false,
  82. sourceMap: false
  83. }),
  84. license({
  85. banner: `
  86. @license
  87. ${name} v${version}
  88. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  89. ${packageJson.license} License
  90. `,
  91. thirdParty: {
  92. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  93. includePrivate: true, // Default is false.
  94. },
  95. })
  96. ]
  97. }