Update the next.config.js file with the following code:
module.exports = {
webpack(config, options) {
if (!options.dev) {
const NextMiniCssExtractPlugin = config.plugins[11];
config.output.filename = config.output.filename.replace('-[contenthash]', '');
config.output.chunkFilename = config.output.chunkFilename.replace('.[contenthash]', '');
config.module.generator.asset.filename = config.module.generator.asset.filename.replace('.[hash:8]', '');
if (NextMiniCssExtractPlugin) {
NextMiniCssExtractPlugin.options.filename = NextMiniCssExtractPlugin.options.filename.replace('[contenthash]', '[name]');
NextMiniCssExtractPlugin.options.chunkFilename = NextMiniCssExtractPlugin.options.chunkFilename.replace('[contenthash]', '[name]');
}
}
return config;
},
...
}
This updated code eliminates the contenthash and hash:8 from the build configuration file names in nextjs. This allows for file names without hashes in the build directory for JavaScript and CSS files.