News for hackers. Stuff that matters.
Re:Webpack 3: Official Release by finchisko on Tuesday June 20, 2017 @06:59AM (#14593510)
I'm kind of surprised how cold reactions are against Webpack here on HN. I consider Webpack by far the best module bundler. My path was: scripts, stealjs, requirejs, requirejs + grunt and also recently tried SystemJS. All of them are pretty awful. Try one of those and you'll realize how amazing Webpack is. For example one of the newer bundler - SystemJS pretty much force you to use jspm package manager. Jspm changes SystemJS configuration on every new package installation, so you can be never sure, if build is failing because jspm changed something. You can forget on imports without providing correct extensions (js,jsx,...), or prepare to fill you config will lot of defaultJSExtensions/file mapping. Also import Module from './module where module is folder with index.js file doesn't work out of the box and mapping has to be added. etc... The only thing I'm personally missing in webpack, is option to provide custom chunk loader, so I can load chunks with any other AMD loader, something similar to requirejs+almodjs or SystemJS static SFX builds, which was the reason I've tried SystemJS at first place, but it wasn't worth the pain.
Re:Webpack 3: Official Release by yunyu on Tuesday June 20, 2017 @07:54AM (#14593802)
Have you tried rollup? Webpack's tree shaking is broken and doesn't work properly with libraries structured like d3, while rollup's works properly. I've managed to get trivial 150kb minified size reductions by switching.
Re:Webpack 3: Official Release by Ralfp on Tuesday June 20, 2017 @08:07AM (#14593893)
But isn't Rollup.js directed at libraries whereas Webpack aims for JS apps?
Re:Webpack 3: Official Release by moron4hire on Tuesday June 20, 2017 @08:10AM (#14593911)
I use Rollup for both, though I don't remember exactly how, as I made a project out of my build setup: https://capnmidnight.github.io/marigold-build
Re:Webpack 3: Official Release by finchisko on Tuesday June 20, 2017 @08:12AM (#14593919)
Rollup looks nice too. As far I understand rollup, it's generating more human readable and shorter bundles, so it's more suitable for libraries. I didn't tried it yet, but I feel somehow that if I do, I will find bad parts there too. Like limited (comparing to webpack) module format support...
Re:Webpack 3: Official Release by yunyu on Tuesday June 20, 2017 @09:04AM (#14594268)
Yeah, it's pretty common (for the tree shaking case) to make a custom d3/whatever library bundle with Rollup and use it with Webpack for your app, but it's a formidable alternative to Webpack regardless.
Re:Webpack 3: Official Release by tjpnz on Tuesday June 20, 2017 @07:50AM (#14593786)
I'm sure it's ok when utilised by skilled hands. But unlike a lot of tools it's just too easy to get things wrong. Possibly by a lack of good documentation or design.

I'm still feeling bitter after seeing it introduced on my last project, a Rails app. Build times went from seconds to 15 minutes. After experiencing that I will make every effort to argue against it's inclusion on my current project (should anyone propose it).

Re:Webpack 3: Official Release by beefsack on Tuesday June 20, 2017 @07:12AM (#14593577)
I use Webpack in a couple of projects, but it only seems to fit well for single page applications that fit their near-standard configurations.

We tried to replace Gulp with it at work for some relatively complex software but it was an absolute nightmare; Webpack is highly opinionated and to get it to build multiple different targets with different configurations requires jumping through a lot of hoops or worse, having to have separate Webpack configs and different build commands for each different asset target.

The last straw for us was how messy it got trying to build our LESS at the same time. Packaging all the LESS into your compiled JS, then having to extract it to put it in other files is absolutely ridiculous.

Re:Webpack 3: Official Release by finchisko on Tuesday June 20, 2017 @07:17AM (#14593597)
That is something I forgot to mention. Webpack is great for SPAs and not so great for classic site with lot of html files. You can have multiple entries (html files), but share common chunks between them might be difficult in some special cases.
Re:Webpack 3: Official Release by cytzol on Tuesday June 20, 2017 @07:53AM (#14593799)
> You can have multiple entries (html files), but share common chunks between them might be difficult in some special cases.

This is what I'm trying to do at the moment -- create a static site that's just a bunch of HTML files, while still taking advantage of Sass, CSS modules, and Vue.js components. (God, I love scoped CSS so much.) I'm sure there's a way to get Webpack to do what I want, but I haven't found it yet. prerender-spa-plugin has been a huge help, though.

It seems very similar to when I was learning Git: I know what I want to do, but Git's interface uses a level one layer lower than the one I'm operating on. "Undo the last commit", not "Reset the working tree to the previous commit's, but leave the staging area intact". Webpack's interface seems too abstract for what I want. I want to think in terms of individual pages, not of entry points; components, rather than chunks. Hopefully in five years when flat HTML files are vogue again there'll be a friendlier interface on top of it all.

Edit: I don't mean to be 100% negative in my comment! Webpack has certainly helped me solve problems that, previously, I haven't been able to solve. That alone is great. I just wish it'll go "click" so I can "get" it.

Re:Webpack 3: Official Release by finchisko on Tuesday June 20, 2017 @08:08AM (#14593897)
If I understand you correctly. You basically want to create completely static website with no javascript (or very little). Something like server side rendering, but without server (or to be precise with only http server) :-). And you've already found webpack module for the job.
Re:Webpack 3: Official Release by cytzol on Tuesday June 20, 2017 @08:14AM (#14593929)
Yeah, you got it. I have a webpack.config.js that compiles everything, bundles it together, and spits out a bunch of HTML files. But what I don't have is the confidence that I'm doing things the right way and not using Webpack inappropriately!
Re:Webpack 3: Official Release by douche on Tuesday June 20, 2017 @10:04AM (#14594697)
Sounds like a plain-old ASP.NET site with Razor partials.
Re:Webpack 3: Official Release by mayank on Tuesday June 20, 2017 @11:19AM (#14595253)
Shameless plug, but I've got a project that builds a static site using Webpack 2 without having to configure it: https://github.com/iceroad/martinet

Contributions welcome!