Skip to content

Instantly share code, notes, and snippets.

@meesvandongen
Created April 15, 2022 19:16
Show Gist options
  • Save meesvandongen/f55549b35cab59040ba1f527586e7551 to your computer and use it in GitHub Desktop.
Save meesvandongen/f55549b35cab59040ba1f527586e7551 to your computer and use it in GitHub Desktop.
Updated next-assets-import for webpack 5
function withAssetsImport(nextConfig = {}) {
return {
...nextConfig,
images: {
disableStaticImages: true,
},
webpack(config, options) {
config.module.rules.push({
test: /\.(bmp|gif|jpe?g|png|svg|ttf|eot|woff2?|mp3|wav|mp4|ogg|webm)$/,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 16 * 1024, // for some reason this must be set quite high; otherwise next will not include images. Needs further investigation.
},
},
});
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options);
}
return config;
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment