我有一个react应用程序,我想为其添加一个 sitemap.xml。我已添加此路由以链接到文件(XML 是我的 sitemap.xml):
import XML from './sitemap.xml';
<Route component={XML} path={'/sitemap.xml'} />
我一直收到这个错误,我明白这意味着我需要向我的 webpack 添加一个 xml 加载器:
You may need an appropriate loader to handle this file type.
不知道如何选择 xml 加载器,因为我主要可以找到解析器(xml 到 json),我不确定在 json 中是否可以使用站点地图。另外,是否有任何其他本机方式可以在不添加任何加载程序的情况下显示 xml 文件?