Webpack: The Missing Tutorial
github.com
github.com
https://www.youtube.com/watch?v=WQue1AN93YU
[1] This thread's post does this too, which is awesome!
You can also separate CSS and SVGs and whatever else you want into external files using the external file plugin.
Finally- there's no reason you need to load the bundle in <head>.
also you don't need to make it a blocking script tag in your <head>, you could load it at the end of <body>, it doesn't prescribe anything.
My big problem with tutorials in JS-land is that so many seem to assume too much background knowledge in the reader. Webpack has been no exception; as someone who generally doesn't do front-end stuff I have really had to dig around to find out how things actually work and find things like lists of valid options for different sections.
IMHO, the speed of the build tool is less of a priority than the speed of the code it produces. You pay the cost of the build tool mostly in integration tests or production builds but shouldn't pay it during development.
However your users pay for inefficiencies times the number of times the app is loaded. The state of JS tooling is woefully behind other languages and IMHO still behind the state of the art 5 years ago. Any non trivial sized app for example will require global dead code analysis and method and field level pruning as your dependencies grow over the lifetime of your app, all apps tend to bloat from unneeded code pulled in.
GWT was the same way, asset packaging was a core feature even in 2009. For example, it would automatically compile CSS, UI templates, and images, auto-optimizing them, and auto-sprite-sheeting everything, while packaging things into as few HTTP requests as possible.
The real issue is that to do this in a safe way for JS requires coding conventions be adhered to, or the adoption of TypeScript and annotations. Closure's advanced mode will break JS that tries to get too fancy with dynamism.
require('style!css!../css/style.css');
What is this I don't even.I have css requires restricted to the client entry file to keep other modules testable/usable server side otherwise.
Rollup or Brunch seem to offer a preferable alternative with speed, ease of use, and optimisation.
Rollup is very similar to Webpack but is architectually different to allow it to optimise assets further and faster.
Brunch has actually been around since before Grunt, it's just not marketed. It works in very simple fashion, just install plugins via npm and start using them, no need to edit configuration files (unless you have very specific requirements).
I would consider Rollup as the new hotness, building upon the success of other tools and starting from a better position to create an optimised tool.
Brunch is a long time standing tool that does a job very well and if your project doesn't require any special configuration or architecture it's so easy to use (it can be configured though).
[0] - https://webpack.github.io/docs/webpack-dev-server.html
> Webpack will perform less-favorably compared to Rollup as the number of modules increases.
The video actually explains what browserify/webpack do, as well as what rollup brings to the table. I don't think it covers brunch, however -- maybe I missed it.
Make sure to watch the video with annotations. There are a lot of related links and clarifications.
Our vision is to be able to integrate as many perf features as possible, (sw-precache, rollup module inlining, a universal generic compressor/minifier for es6).