rollup.treeshake.config.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import path from 'path';
  2. import resolve from '@rollup/plugin-node-resolve';
  3. import filesize from 'rollup-plugin-filesize';
  4. import terser from '@rollup/plugin-terser';
  5. import { visualizer } from 'rollup-plugin-visualizer';
  6. import { glsl } from '../utils/build/rollup.config.js';
  7. import chalk from 'chalk';
  8. const statsFile = path.resolve( 'test/treeshake/stats.html' );
  9. function logStatsFile() {
  10. return {
  11. writeBundle() {
  12. console.log();
  13. console.log( 'Open the following url in a browser to analyze the tree-shaken bundle.' );
  14. console.log( chalk.blue.bold.underline( statsFile ) );
  15. console.log();
  16. }
  17. };
  18. }
  19. export default [
  20. {
  21. input: 'test/treeshake/index.js',
  22. plugins: [
  23. resolve()
  24. ],
  25. output: [
  26. {
  27. format: 'esm',
  28. file: 'test/treeshake/index.bundle.js'
  29. }
  30. ]
  31. },
  32. {
  33. input: 'test/treeshake/index.js',
  34. plugins: [
  35. resolve(),
  36. terser(),
  37. filesize( {
  38. showMinifiedSize: false,
  39. } )
  40. ],
  41. output: [
  42. {
  43. format: 'esm',
  44. file: 'test/treeshake/index.bundle.min.js'
  45. }
  46. ]
  47. },
  48. {
  49. input: 'test/treeshake/index-src.js',
  50. plugins: [
  51. glsl(),
  52. terser(),
  53. visualizer( {
  54. filename: statsFile,
  55. } ),
  56. logStatsFile()
  57. ],
  58. output: [
  59. {
  60. format: 'esm',
  61. file: 'test/treeshake/index-src.bundle.min.js'
  62. }
  63. ]
  64. },
  65. {
  66. input: 'test/treeshake/index.webgpu.js',
  67. plugins: [
  68. resolve()
  69. ],
  70. output: [
  71. {
  72. format: 'esm',
  73. file: 'test/treeshake/index.webgpu.bundle.js'
  74. }
  75. ]
  76. },
  77. {
  78. input: 'test/treeshake/index.webgpu.js',
  79. plugins: [
  80. resolve(),
  81. terser(),
  82. filesize( {
  83. showMinifiedSize: false,
  84. } )
  85. ],
  86. output: [
  87. {
  88. format: 'esm',
  89. file: 'test/treeshake/index.webgpu.bundle.min.js'
  90. }
  91. ]
  92. },
  93. {
  94. input: 'test/treeshake/index.webgpu.nodes.js',
  95. plugins: [
  96. resolve()
  97. ],
  98. output: [
  99. {
  100. format: 'esm',
  101. file: 'test/treeshake/index.webgpu.nodes.bundle.js'
  102. }
  103. ]
  104. },
  105. {
  106. input: 'test/treeshake/index.webgpu.nodes.js',
  107. plugins: [
  108. resolve(),
  109. terser(),
  110. filesize( {
  111. showMinifiedSize: false,
  112. } )
  113. ],
  114. output: [
  115. {
  116. format: 'esm',
  117. file: 'test/treeshake/index.webgpu.nodes.bundle.min.js'
  118. }
  119. ]
  120. }
  121. ];