【问题标题】:angular-cli rename index on build构建时的 angular-cli 重命名索引
【发布时间】:2017-01-08 21:35:13
【问题描述】:

我想重命名 dist 文件夹上的 index.html,我如何使用 angular cli on ng build --prod 命令来做到这一点。

让我解释一下我为什么要这样做,它是为了将我的 html 页面集成到 index.php 页面上,如果我不这样做服务器在 index.php 之前回复 index.html 并且我无法配置服务器首先启动 index.php。

感谢您的回复。

【问题讨论】:

    标签: php angular angular-cli


    【解决方案1】:
    1. 在项目的 src 目录中将文件 index.html 重命名为 index123.html

    2. 在文件 angular-cli.json 中修改 index 属性,如下所示:

      “索引”:“index123.html”

    ng build 命令会将文件 index123.html 复制到 dist 目录中。

    【讨论】:

    • 你好,我试试这个,但是在 localhost:4200 上使用 ng serve 你必须指定索引的新名称:localhost:4200/index123.html 并且我的应用程序不再加载
    • ng serve 在内存中创建 Angular 应用程序包。根据您最初的问题,您希望将您的应用程序部署在部署 PHP 代码的另一台服务器下。运行 ng build 后,需要将 dist 目录的内容复制到 index.php 所在的服务器。
    • 我用 index.php 和 index.html 生成 dist,我的目标是让 ng 像实际一样服务并在没有手动操作的情况下将 dist 部署到服务器,但是如果我在 src 应用程序上重命名 index.html,我的本地主机停止工作。
    猜你喜欢
    • 2017-10-08
    • 2017-03-24
    • 2015-11-06
    • 2018-03-06
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    • 2013-11-19
    相关资源
    最近更新 更多