【问题标题】:Angular CLI: Mount app to domain subpath - relative paths for static filesAngular CLI:将应用程序挂载到域子路径 - 静态文件的相对路径
【发布时间】:2016-12-14 22:27:52
【问题描述】:

我使用 ng build --prod 构建的 Angular2 应用程序已安装到 https://[domainname]/app。 问题是 index.html 中注入的脚本和样式的路径类似于

src="styles.8e0edbbd6ad2cb36be49.bundle.js"

所以页面正在尝试在根目录中查找它们。 如何将其更改为:

src="./styles.8e0edbbd6ad2cb36be49.bundle.js"

或者是否有其他正确的方法可以使用 Angular CLI 将应用程序部署到域子路径?

【问题讨论】:

    标签: angular angular-cli


    【解决方案1】:

    使用以下命令使用 cli 构建 angular 2

    # Sets base tag href to /myUrl/ in your index.html
    ng build --base-href /myUrl/
    ng build --bh /myUrl/
    

    【讨论】:

      猜你喜欢
      • 2018-12-13
      • 2020-01-18
      • 2013-12-20
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2018-12-05
      • 1970-01-01
      相关资源
      最近更新 更多