简体   繁体   中英

Ember-cli /dist files do not run when run directly

I have a ember cli project and when running ember server it works, however if I try run the /dist/index.html directly it cannot find the files such as dist/assets/vendor.js

I need these files to work as I will be sharing this code to run in a server.

在此输入图像描述

在此输入图像描述

An http server is required because of the <base> tag in the index.html file that specifies the base URL to use for all relative URLs contained within a document. So when your app is trying to serve up the assets/app.js or assets/vendor.js, its trying to look relative to this base url, which is defined in config/environment.js. It defaults to /. So you need a server to respond to the resource requests for the assets. Notice that your assets folder is relative to the index.html file, but inside the dist folder which is not treated the same as / by your browser

tl;dr You can't just double click your application's index.html , open it in a browser, and expect it to work. It must be served

The dist folder is production ready code, minifed and ready to go, that you deploy to your server when ready. You copy the files from this folder to your production server so the issue youre facing now - in that your dist index.html is looking for assests in the assets folder rather in the dist/assets folder wont be an issue. The dist code is the same as your other code so if your other code is working then the dist code should be fine. On a side note what do you mean run the dist/index.html directly?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM