terserOptions.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module.exports = options => ({
  2. terserOptions: {
  3. compress: {
  4. // turn off flags with small gains to speed up minification
  5. arrows: false,
  6. collapse_vars: false, // 0.3kb
  7. comparisons: false,
  8. computed_props: false,
  9. hoist_funs: false,
  10. hoist_props: false,
  11. hoist_vars: false,
  12. inline: false,
  13. loops: false,
  14. negate_iife: false,
  15. properties: false,
  16. reduce_funcs: false,
  17. reduce_vars: false,
  18. switches: false,
  19. toplevel: false,
  20. typeofs: false,
  21. // a few flags with noticeable gains/speed ratio
  22. // numbers based on out of the box vendor bundle
  23. booleans: true, // 0.7kb
  24. if_return: true, // 0.4kb
  25. sequences: true, // 0.7kb
  26. unused: true, // 2.3kb
  27. // required features to drop conditional branches
  28. conditionals: true,
  29. dead_code: true,
  30. evaluate: true
  31. },
  32. mangle: {
  33. safari10: true
  34. }
  35. },
  36. sourceMap: options.productionSourceMap,
  37. cache: true,
  38. parallel: options.parallel,
  39. extractComments: false
  40. })