我有一个反应应用程序,我想为其添加一个 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 文件而不添加任何加载程序?