petehunt / webpack-howto

10.11k stars 696 forks source link

Further explanation of the webpack optimizer #5

Closed nmn closed 10 years ago

nmn commented 10 years ago

It would be great to go into some more detail on how the webpack.optimize actually works.

Another things I'm pretty concerned about is code re-use on the server-side.

Webpack is often touted as a better alternative to browserify. But browserify has the unique strength of seamlessly working within node.js. Considering that the benefits of webpack come with async loading and 'require.ensure', and requiring static files, is there a way to make these lines work in node.js as well? They mostly just need to be ignored.

petehunt commented 10 years ago

webpack has enhanced-require which replaces Node's require(), but the best way to do it is to run webpack --target node and then run those bundles in Node.

Since we don't actually use either of these things in production at Instagram I'm not comfortable writing a howto (I'd prefer that everything in this document has actually been used in production with something nontrivial) -- but if anyone has I'd accept a contribution.

As far as optimizer docs go I'm not sure webpack-howto is a good place for that. The official webpack docs do cover this though:

http://webpack.github.io/docs/optimization.html http://webpack.github.io/docs/code-splitting.html

Please reopen if you have further questions -- thanks!