1
0

rollup.treeshake.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 { glconstants, 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. glconstants(),
  52. glsl(),
  53. terser(),
  54. visualizer( {
  55. filename: statsFile,
  56. } ),
  57. logStatsFile(),
  58. ],
  59. output: [
  60. {
  61. format: 'esm',
  62. file: 'test/treeshake/index-src.bundle.min.js'
  63. }
  64. ]
  65. },
  66. ];