Created
April 15, 2022 19:16
-
-
Save meesvandongen/f55549b35cab59040ba1f527586e7551 to your computer and use it in GitHub Desktop.
Updated next-assets-import for webpack 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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