问题
I'm trying to set up a basic seed for an Angular / Electron app. I've worked it up from scratch based on a handful of guides and articles and it works fine whilst developing but fails when I go to build it.
Project Source
git clone https://popClingwrap@bitbucket.org/popClingwrap/angular-electron-seed.git
If you do npm start
then npm run electron
at the same time in a second terminal the app will fire up fine in both a browser and then in an Electron app window. If you click the button on screen it will create a new directory on your desktop so everything seems to be hooked up ok.
If you then do npm run build
it will bundle everything up without any errors but I thought I should then be able to serve the bundles and see the app run in browser again. However if I do npm run dev
to start a server in the /dist
directory I just get a list of errors for both javascript and style sheets saying
Refused to apply styles from / Refused to execute script from [url] because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
I'll confess I'm struggling to understand the details of a lot of what is going on in this build especially where WebPack is concerned. Can anyone tell me what is going wrong here and what I might try to fix the issue?
Cheers all
回答1:
In the index.html, Please verify whether the below code is same like this(incase if it is missing please add this in index.html) :
<base href="/">
This has solved my problem.
来源:https://stackoverflow.com/questions/49603177/bundled-js-fails-mime-type-text-html-is-not-executable-and-strict-mime-ty