Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images within client-side-only loaded components aren’t optimized #282

Closed
psirenny opened this issue May 30, 2022 · 1 comment
Closed

Comments

@psirenny
Copy link

psirenny commented May 30, 2022

Images within client-side-only loaded components aren’t optimized. For example:

✅ This works

import dynamic from 'next/dynamic';
import type { NextPage } from 'next';
import ComponentWithImage from './ComponentWithImage';

export const Page: NextPage = () => (
  <main>
    <h1>Title</h1>
    <ComponentWithImage />
  </main>
);

❌ This doesn't work

import dynamic from 'next/dynamic';
import type { NextPage } from 'next';

const ClientSideComponentWithImage = dynamic(
  async () => await import('./ComponentWithImage'),
  { ssr: false }, // The problem
);

export const Page: NextPage = () => (
  <main>
    <h1>Title</h1>
    <ClientSideComponentWithImage />
  </main>
);

The .next/custom-optimized-images.nd.json manifest isn't populated with the dynamic images during next build.

@psirenny
Copy link
Author

Sorry, I posted this issue in the wrong repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant