rollup.treeshake.config.js 2.1 KB

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