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

Compatible with Next 13? #287

Open
codaisa opened this issue Nov 9, 2022 · 2 comments
Open

Compatible with Next 13? #287

codaisa opened this issue Nov 9, 2022 · 2 comments

Comments

@codaisa
Copy link

codaisa commented Nov 9, 2022

I am not able to configure the package very well in Next 13, is it already compatible with this version?

@Idlesome
Copy link

Running [email protected] here and found that next-env.d.ts getting overwritten causes this issue. I added my own types.d.ts at the root of my project and added:

/// <reference types="next/image-types/global" />
/// <reference types="optimized-images-loader" />

There instead of in next-env.d.ts and the "type error cannot find module *.jpg" (also referenced here) went.

I also had to add:

  images: {
    disableStaticImages: true,
+   unoptimized: true,
  },

To my next.config.js and use withOptimisedImages instead of using the plugins composer to get rid of next build error. My full next.config.js for reference:

const withOptimizedImages = require("next-optimized-images");

/** @type {import('next').NextConfig} */
const nextConfig = {
  images: {
    disableStaticImages: true,
    unoptimized: true,
  },
};

module.exports = withOptimizedImages(nextConfig);

All seems to working fine for me now :) FYI I'm using canary build 3.0.0-canary.10

@wonrax
Copy link

wonrax commented May 13, 2023

It works for me in dev mode but not in build mode with {output: "export"}. The out directory doesn't seem to contains any generated images. "next": "^13.4.1".

Edit: Fixed it by using @hashicorp/next-optimized-images (https://github.com/hashicorp/web-platform-packages/tree/main/packages/next-optimized-images).

My next.config.js (do note that I use export mode):

const { withContentlayer } = require("next-contentlayer");
const withOptimisedImages = require("@hashicorp/next-optimized-images");

const nextConfig = {
  output: "export",
  images: {
    disableStaticImages: true,
    unoptimized: true,
  },
};

module.exports = withContentlayer(
  withOptimisedImages({
    ...nextConfig,
    // responsive: {
    //   adapter: require("responsive-loader/sharp"),
    //   sizes: [320, 640, 960, 1200, 1800, 2400],
    //   placeholder: true,
    //   placeholderSize: 20,
    // },
  })
);

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

3 participants