[英]React app not rendering CSS, i have added CSS file in index.html
[英]bundled css is added at the top of index.html
在構建我的 Angular 9.0.4 應用程序的 prod 版本時,css 被捆綁並添加到 dist/index.html 的頂部,如下所示:
<link rel="stylesheet" href="styles.6ea28d52542acb20a4c6.css"><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MyTitle</title>
<base href="/">
我認為這是導致 Chrome 中的警告:
Resource interpreted as Stylesheet but transferred with MIME type text/html:
並且樣式表未正確呈現。 請注意,這僅在加載帶有子文件夾的域時發生,例如www.mydomain.com/product/1
是否可以配置構建,以便在<base href="/">
下面添加樣式表元素,這可能會修復警告?
我不知道移動 css 文件導入的任何方法,但是您可以通過關閉 css 提取來停止此錯誤:
紗線構建 --extractCss=false
或在 angular.json 中的構建配置中
{
...
"build": {
"configurations": {
"yourBuildName": {
...
"extractCss": false
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.