Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
fix(@plaiceholder/next): add sharp to webpack externals
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-bell committed Jun 13, 2021
1 parent a3720a3 commit 76a49be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 0 additions & 7 deletions examples/next/next.config.js
Expand Up @@ -4,13 +4,6 @@ module.exports = withPlaiceholder({
images: {
domains: ["images.unsplash.com"],
},
webpack: (config) => {
config.externals.push({
sharp: "commonjs sharp",
});

return config;
},
future: {
webpack5: true,
},
Expand Down
16 changes: 14 additions & 2 deletions packages/next/src/index.ts
@@ -1,5 +1,17 @@
export const withPlaiceholder = (config) => {
export const withPlaiceholder = (nextConfig) => {
require("sharp");

return config;
return Object.assign({}, nextConfig, {
webpack(config, options) {
config.externals.push({
sharp: "commonjs sharp",
});

if (typeof nextConfig?.webpack === "function") {
return nextConfig.webpack(config, options);
}

return config;
},
});
};

0 comments on commit 76a49be

Please sign in to comment.