Firebase“将资源解释为样式表,但以MIME类型text/html传输" [英] Firebase "Resource interpreted as Stylesheet but transferred with MIME type text/html"

查看:98
本文介绍了Firebase“将资源解释为样式表,但以MIME类型text/html传输"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Web应用程序(只是一些HTML,SCSS和JavaScrip),并将其与包裹捆绑在一起.当我在本地主机(由包裹提供)上运行该应用程序时,一切正常.但是,一旦我在Firebase本地主机上启动它,CSS就无法正常工作.我收到此错误:

I created a web app (just some HTML, SCSS and JavaScrip) and bundled it with parcel. When I run the app on localhost (served by parcel), everything works totally fine. But as soon as I start it on the firebase localhost, the CSS is not working. I get this error:

资源被解释为样式表,但以MIME类型text/html传输

Resource interpreted as Stylesheet but transferred with MIME type text/html

有人有一个主意,如何解决这个问题?

Does anyone have an idea, how to solve this?

感谢您的帮助!

推荐答案

Sidney疯狂地猜测着他.捆绑的index.html中指向样式表和图像的链接不正确.Parcel引用了dist文件夹,在该文件夹中,他应该直接引用了这些文件.我能够手动更改来自的链接

Sidney was wright with his wild guess. The link to the stylesheet and the images weren't correct in the bundled index.html. Parcel referred to the dist folder, where he should have referred directly to the files. I was able to manually change the links from

<link rel="stylesheet" href="/dist/natalem-20.css">

<link rel="stylesheet" href="/natalem-20.css">

然后一切正常.

由于Firebase无法找到正确的样式表,因此他只是将HTML作为.css文件发送回去.因此,控制台中没有404错误,但是警告了

Because Firebase wasn't able to find the correct stylesheet, he just sent back the HTML as .css - file. Because of that, there was no 404-error in the console but the warning

资源被解释为样式表,但以MIME类型text/html传输

Resource interpreted as Stylesheet but transferred with MIME type text/html

因此,要解决此问题,只需更改捆绑的index.html中的路径,或者(我现在要执行的操作)是要弄清楚如何在宗地配置中更改此路径.

So to fix the problem, just change the path in the bundled index.html or (what I'm gonna do now) is to figure out, how to change this over the Parcel config.

非常感谢Sidney的帮助!给你做道具!

Thanks a lot to Sidney for the help! Props to you!

真诚的,

拉斐尔

这篇关于Firebase“将资源解释为样式表,但以MIME类型text/html传输"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆