build.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. const rewire = require('rewire');
  2. const defaults = rewire('react-scripts/scripts/build.js');
  3. const config = defaults.__get__('config');
  4. //config.optimization.minimize = false;
  5. // Consolidate chunk files instead
  6. config.optimization.splitChunks = {
  7. cacheGroups: {
  8. default: false,
  9. },
  10. };
  11. // Move runtime into bundle instead of separate file
  12. config.optimization.runtimeChunk = false;
  13. // JS
  14. config.output.filename = '[name].js';
  15. // config.optimization.minimizer[0].options.terserOptions = {
  16. // ecma: undefined,
  17. // warnings: false,
  18. // parse: {},
  19. // compress: {},
  20. // mangle: true, // Note `mangle.properties` is `false` by default.
  21. // module: false,
  22. // output: null,
  23. // toplevel: false,
  24. // nameCache: null,
  25. // ie8: false,
  26. // keep_classnames: undefined,
  27. // keep_fnames: false,
  28. // safari10: false,
  29. //};
  30. config.optimization.minimizer[0].options.terserOptions.keep_classnames = true;
  31. config.optimization.minimizer[0].options.terserOptions.keep_fnames = true;
  32. console.log(config.optimization.minimizer[0]);
  33. // CSS. "5" is MiniCssPlugin
  34. config.plugins[5].options.filename = '[name].css';
  35. config.plugins[5].options.publicPath = '../';