Should I minimize node_modules, or should I use the mini version for deployment on the client?

I recently switched to webpack from require.js, and some node_module had .min files embedded. When I use the file from node_module, I just do require('my-module')it and it loads it right away without any configuration. But this will load a development version or a larger version.

For example, the reaction is loaded require('react/addons'), but this is not an abridged version.

My question is:

  • Should I load the modules normally, and then still cut back?
  • Should I use their .min files provided and then still mine? (this way I save a lot of disk)
  • The best way? It would be nice to automatically disable thumbnail files.

I am currently modifying webpack aliases to load a mini version when creating the application:

myConfig.resolve.alias.phaserUnFixed = "nodeModules/phaser/build/custom/phaser-no-physics.min.js";
myConfig.resolve.alias.react = "nodeModules/react/dist/react-with-addons.min.js";
myConfig.resolve.alias.lodash = "nodeModules/lodash/dist/lodash.compat.min.js";
myConfig.resolve.alias.moment = "nodeModules/moment/min/moment.min.js";

But this is also a bad approach ... Can you come up with something better?

+4
source share
1 answer

I don’t know if this is the answer you are looking for, but I think that the best practice in this case would be to use webpack to guess it for production and not worry about uploading mini files. If webpack runs uglify on the whole package, cuts out all unused codecs, and then reduces it anyway.

+1
source