gpt4 book ai didi

reactjs - React Nextjs : Module parse failed:You may need an appropriate loader to handle this file type, 当前没有配置加载器来处理这个文件

转载 作者:行者123 更新时间:2023-12-05 01:54:09 27 4
gpt4 key购买 nike

我正在尝试加载 pdf 文件

import placeholder from "../assets/pdf/placeholder.pdf"

每次服务器重新加载时,我都会收到此错误:*错误 - ./assets/pdf/placeholder.pdf模块解析失败:意外标记 (1:0)您可能需要一个合适的加载器来处理这种文件类型,目前没有配置加载器来处理这种文件。参见 https://webpack.js.org/concepts#loaders(此二进制文件省略了源代码)*

最佳答案

如果您使用的是 Webpack4,您似乎需要 raw-loader

https://v4.webpack.js.org/loaders/raw-loader/

{
test: /\.pdf$/i,
use: 'raw-loader',
}

如果您使用的是 Webpack5,则可以使用新的 Assets 模块:

https://webpack.js.org/guides/asset-modules/

(原始加载程序替换)

{
test: /\.pdf$/i
type: 'asset/source'
}

(文件加载器替换)

{
test: /\.pdf$/i
type: 'asset/resource',
generator: {
filename: `[name][ext]`
}
}

关于reactjs - React Nextjs : Module parse failed:You may need an appropriate loader to handle this file type, 当前没有配置加载器来处理这个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70805853/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com