rollup.treeshake.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ];