🚨 This setup is highly custom and works based on the specific implementation of the build process in Next.js 4.x. With the release of Next 5.x this setup will not work anymore and will likely be replaceable by a much simpler/vanilla Webpack config.
How Deliveroo are using Next.js and CSS modules.
All our static assets are built by extending the next webpack config, and pushed to a CDN when deploying.
Everything in dist/static
gets mounted at /static
at the CDN
The build script in package.json
looks like this:
next build ./app
next export -o app/dist/export ./app
mv app/dist/export/_next app/dist/
rm -r app/dist/export
- Our next config extends webpack heavily. We're hoping plugins in Next 5 will replace most of this
- We include include links to generated CSS files with
<PageStylesheet>
- We're not using client routing yet, so this setup may not work when navigating between pages locally