Skip to content

nextConfiguration not working as expected #42

@olikami

Description

@olikami

In my understanding, this is how my next.config.js should look:

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);

This however break the usage of the next/Image tag.

If found a fix/hack by changing my module.exports:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions