const withPlugins = require('next-compose-plugins');
const nextImages = require('next-images');
const bundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const nextConfig = {
async rewrites() {
return [
{
source: '/sitemap.xml',
destination: '/api/sitemap',
},
];
},
webpack: (config, options) => {
config.module.rules.push({
test: [/\.jpe?g$/, /\.png$/, /\.svg$/],
use: [
options.defaultLoaders.babel,
{
loader: 'sizeof-loader',
options: {
limit: 5000,
publicPath: '/_next/static/images/',
outputPath: 'static/images/',
name: '[name].[hash:8].[ext]',
},
},
],
});
return config;
},
images: {
domains: ['<private domain>'],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384, 400, 500],
deviceSizes: [640, 750, 828, 960, 1080, 1200, 1920, 2048, 3840],
},
};
module.exports = withPlugins([
[bundleAnalyzer],
[nextImages],
], nextConfig);
module.exports = withPlugins([
[bundleAnalyzer],
[nextImages],
nextConfig
]);
This works, but doesn't follow the usage example form the README. This somehow also breaks the bundleAnalyzer.
Am I missing something here? Happy to provide any additional information.
In my understanding, this is how my
next.config.jsshould look:This however break the usage of the
next/Imagetag.If found a fix/hack by changing my module.exports:
This works, but doesn't follow the usage example form the README. This somehow also breaks the
bundleAnalyzer.Am I missing something here? Happy to provide any additional information.