Example repo: https://github.com/sbking/nextjs-dynamic-import-distdir
This example shows that dynamic import webpack chunks return 404 errors in production builds if a custom distDir is set in next.config.js. This is simply the with-dynamic-imports example with the following next config:
const config = {
distDir: 'build',
}
module.exports = config
The dynamic imports work perfectly in development mode, but give 404 errors in a production build.