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 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 glsl from "rollup-plugin-glsl"
  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. glsl({ // todo: minify glsl.
  56. include: "src/**/*.glsl"
  57. }),
  58. postcss({
  59. modules: false,
  60. autoModules: true, // todo; issues with typescript import css, because inject is false
  61. inject: false,
  62. minimize: isProduction,
  63. // Or with custom options for `postcss-modules`
  64. }),
  65. json(),
  66. resolve({}),
  67. typescript({}),
  68. commonjs({
  69. include: 'node_modules/**',
  70. extensions: ['.js'],
  71. ignoreGlobal: false,
  72. sourceMap: false
  73. }),
  74. license({
  75. banner: `
  76. @license
  77. ${name} v${version}
  78. Copyright 2022<%= moment().format('YYYY') > 2022 ? '-' + moment().format('YYYY') : null %> ${author}
  79. ${packageJson.license} License
  80. `,
  81. thirdParty: {
  82. output: path.join(__dirname, 'dist', 'dependencies.txt'),
  83. includePrivate: true, // Default is false.
  84. },
  85. })
  86. ]
  87. }