News for hackers. Stuff that matters.
Re:Why we switched from Webpack to Vite by JMTQp8lwXL on Wednesday April 28, 2021 @03:38PM (#26973213)
As the "webpack" guy on my team, these numbers look extremely compelling, but I also know Webpack does a lot for us (e.g., through Webpack v4, it includes browserfied node libs as needed). Beyond node libs, there's a long tail of niche things that need to be taken of... am I trading coverage of that long tail for speed?
Re:Why we switched from Webpack to Vite by judofyr on Wednesday April 28, 2021 @04:19PM (#26973681)
Previously I've been a heavy user of Webpack + plugins, but I've now moved over to ESBuild for all new projects. This means letting go of many fancy features, but the overall complexity is so much reduced and I'm a lot happier.

Before: Chain together style-loader, css-loader, postcss-loader and the MiniCssExtractPlugin in some weird way. So complicated to understand which PostCSS plugins interacts with resolving imports. I often need to look into the webpack.config.js to understand how everything work. After: Use PostCSS and its tooling for CSS. Yes, there's now a separate process I also need to run in order to watch and build CSS. Yes, I can no longer `import "./style.css"` from the JavaScript files. But it's so much easier to reason about! The CSS tooling creates a CSS file; the JavaScript tooling creates a JavaScript file. Do I want to build SVG sprites? Well, that can very easily be a separate script which I can debug independently and _not_ couple into my builder's plugin system.

In addition, now my JavaScript files are actually just JavaScript and I can be pretty sure that it will work with any new tooling without any problems. Once the successor to ESBuild comes out I will most likely be able to point it at index.js and everything will work.

Re:Why we switched from Webpack to Vite by girvo on Thursday April 29, 2021 @09:30AM (#26980909)
It’s funny to me that we’ve sort of ended up back where I started with Browserify and a seperate Less compile step, or even further back with require.js in some ways.

It’s smart though. Despite having built webpack plugins myself, my main gripe with it was how overloaded it became.

Re:Why we switched from Webpack to Vite by jeswin on Thursday April 29, 2021 @12:25AM (#26977460)
This is excellent advice. There's something I really dislike about import "./style.css" into JS files - it just seems meaningless especially if you've worked with other languages/ecosystems. A great many tutorials default to this style, so it'll likely live on for a while.

As yet another tiny UI framework creator (forgojs.org), the switch to esbuild-loader was our best developer experience decision. create-forgo-app (our CRA equivalent) takes 3-4 seconds, and running it is instantaneous. Faster builds actually change the way developers write code.

Re:Why we switched from Webpack to Vite by viklove on Thursday April 29, 2021 @01:00AM (#26977639)
One great problem it solves is namespacing all of your styles. I don't have to worry about classname collisions because the bundle handles it all for me. Instead of having one massive global stylesheet, I have a bunch of small, modular stylesheets that fit entirely on my display without scrolling, and I can reason about the output much easier than before.
Re:Why we switched from Webpack to Vite by panzerklein on Thursday April 29, 2021 @11:55AM (#26982790)
You're talking about css modules. It's a different feature.
Re:Why we switched from Webpack to Vite by eliseumds on Thursday April 29, 2021 @09:53AM (#26981173)
Plus effortless code splitting.
Re:Why we switched from Webpack to Vite by acdha on Wednesday April 28, 2021 @05:07PM (#26974208)
> In addition, now my JavaScript files are actually just JavaScript and I can be pretty sure that it will work with any new tooling without any problems.

That's been my feeling for years, too: if your team is less than, say, several dozen people there's a significant amount of merit to having something which doesn't require continous care and feeding for anyone to work, especially when it's combining a number of complex libraries with independent development teams.

Re:Why we switched from Webpack to Vite by jakelazaroff on Wednesday April 28, 2021 @06:22PM (#26974989)
In my experience, the vast majority of use cases are covered by these "no config" tools. If your app isn't a typical CRUD app you might fall into that long tail, but FWIW almost every app I've built has not :)
Re:Why we switched from Webpack to Vite by vijaybritto on Wednesday April 28, 2021 @03:51PM (#26973360)
You still can do polyfills manually via browserify packages
Re:Why we switched from Webpack to Vite by desireco42 on Wednesday April 28, 2021 @04:31PM (#26973810)
You still need webpack for production build :). So all is good.
Re:Why we switched from Webpack to Vite by darekkay on Wednesday April 28, 2021 @05:32PM (#26974488)
Vite uses Rollup for production builds, which is still much faster than webpack.
Re:Why we switched from Webpack to Vite by simlevesque on Wednesday April 28, 2021 @06:33PM (#26975098)
Why can't you use esbuild for production builds ?
Re:Why we switched from Webpack to Vite by RobertKerans on Wednesday April 28, 2021 @07:14PM (#26975432)
Tree shaking isn't sorted, so can't currently get an bundle optimised to same extent as you do with Webpack/Rollup et al. It'll come, but not quite there yet.
Re:Why we switched from Webpack to Vite by eliseumds on Thursday April 29, 2021 @10:08AM (#26981349)
Correct.
Re:Why we switched from Webpack to Vite by desireco42 on Wednesday April 28, 2021 @11:53PM (#26977261)
Yes you can, my bad/ But some people have webpack configs, so the easiest for them is to keep those and can use Vite for development. Like if you are not doing new project.
Re:Why we switched from Webpack to Vite by IggleSniggle on Wednesday April 28, 2021 @08:08PM (#26975810)
I use esbuild for prod...?