【发布时间】:2021-02-17 23:35:25
【问题描述】:
我正在尝试使用 next-optimized-images 优化我的 nextjs 页面图像
这是下一个.config.js:
module.exports = {
...
withOptimizedImages: withOptimizedImages({
webpack(config) {
config.resolve.alias.images = path.join(__dirname, 'public')
return config
}
}),
...
这是我将图像导入组件的方法:
require(`public/assets/icons/${iconName}`)
我的错误:
./public/assets/icons/website/information/hiring-black.svg 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
我正在使用最新版本的 next-optimized-image 并尝试了不同的指南,但仍然没有运气。 请帮忙
【问题讨论】:
标签: performance frontend next.js webpack-4