我的机器和开发环境是:Mac 10.11.4 angular-cli:1.0.0-beta.10 node:5.11.1 os:darwin x64
该项目是从Angular CLI创建的。运行'ng serve --prod'时应用程序运行正常,但是当我运行'ng build --prod'然后发布直播时,我可以发现很多错误,无法找到资源。
在index.html中加载这些资源有很多“魔力”,所以我不知道如何解决这个问题....
https://github.com/JimTheMan/Safe-Foods/tree/gh-pages
我的项目名为“SafeFoods”。正确的路径,例如es6-shim.js,应该是:https://jimtheman.github.io/Safe-Foods/vendor/es6-shim/es6-shim.js实际上是:https://jimtheman.github.io/vendor/es6-shim/es6-shim.js
ng build任务每次都会这样创建它所以我不确定如何告诉它正确的路径......
注意:我也尝试将angular-cli更新到最新版本并使用'--base-href',但这似乎没有正常运行:
SafeFoods(gh-pages)buildng build --prod --base-href / Safe-Foods /
选项'--base-href'未在build命令中注册。运行build --help以获取支持的选项列表。
任何帮助表示赞赏。谢谢。
在config/environment.js
设置baseURL: '/Safe-Foods'
。
在src/index.html
设置<base href="{{ baseURL }}">
。