reactjs - npm run build 后未找到清单和其他几个静态文件(字体)
问题描述
npm run build 后未找到清单和其他几个静态文件(字体)。
该应用程序由create-react-app
.
在里面public/index.html
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
文件出现在 build 文件夹中并成功部署。我可以使用 Azure Kudu 服务找到它们。favicon.ico 和其他静态元素运行良好。只有清单和两种字体存在问题。
对于本地运行:
"app:start": "react-app-env --env-file=dev.env start"
"start": "npm run app:start"
对于构建:
"app:dev": "react-app-env --env-file=dev.env build"
"build": "npm run semantic:build && npm run app:build"
"semantic:build": "gulp build --gulpfile ./src/semantic/gulpfile.js"
获取https://public.url/manifest.json 404
清单:行:1,列:1,语法错误。
获取https://public.url/static/media/icons.af7ae505.woff2 net::ERR_ABORTED 404
获取https://public.url/static/media/icons.fee66e71.woff net::ERR_ABORTED 404
解决方案
已修复。将一段代码添加到public/web.config
:
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/x-woff" />
</staticContent>
推荐阅读
- sockets - 如何解密 bet365 套接字数据
- c# - “玩家”游戏对象没有附加“刚体”,但脚本正在尝试访问它
- r - 在哪里将进度条代码插入嵌套循环?
- php - mysql查询中表名的语法错误
- angular - 如果后端刷新令牌成功,如何做可见组件
- sql - 如何使用 Vertica AVG [分析]
- javascript - Woocommerce,如何编辑“已添加到购物车”消息并实现通知系统
- javascript - 如何将库 (p5.js) 添加到 Stackblitz IDE?
- angular - Angular 7将firebase UserInfo映射到自定义用户模型
- javascript - 我怎样才能让这个虚拟键盘上的按钮在点击后消失