Wegmans came to us with a predicament: they had developed a brilliant recommendation system that suggests recipes based on your shopping history. We had helped get these recipes to display on their site’s homepage, but as you might guess, the most important time for shoppers to see relevant recipes is just-in-time—when cracking open the Wegmans app in-store before this week’s haul.
At first glance, this seemed like a straightforward task. The recommendations are requested by some in-page JavaScript, brewed on-the-fly, and then piped onto the page’s HTML. While the official app is HTML-and-JavaScript-based, it exists in a separate system with its own development cycle that would have made rapid iteration and style consistency between site and app more difficult.
What we needed to do was create a self-inflating version of these recipe components that would allow them to appear anywhere there is JavaScript access, including places we didn’t have control over the server-side markup or CSS. This certainly sounded like a job for a JavaScript framework.
While React is certainly the frontend community’s collective darling, it can be a little too Swiss-army-knife for smaller projects. Vue, a fast-growing underdog, has taken some of the concepts that make React great and packaged it into a more lightweight and succinct package. For this focused purpose—standalone widgets that can be embedded everywhere—it was a perfect fit.
We split apart the pieces of the UI into self-contained Vue components that can be entirely customized through the data and variables passed to it, including goodies like randomizing recipe order and applying background flair. To keep things consistent with the website, we also wired these components into Wegmans’ WordPress admin interface.
OK, so we have these Vue components, but they come with some baggage: custom CSS, third-party JS (like the Swiper slider library), and other odds-and-ends like icon fonts. Because the app would be loading our code on top of its own resources, adding all of these things in independent
Enter Webpack. While it describes itself as a module bundler, a wordier but more accurate description would be “Just about any type of web file translator, compressor, packager and loader” (Should I be on their branding team?).