【问题标题】:AngularCli Preconfigured build parametersAngular Cli 预配置的构建参数
【发布时间】:2017-06-08 08:13:36
【问题描述】:

在 AngularCli 项目中,有命令 ng build 在开发环境中运行良好,但对于发布,我需要一些额外的选项,例如

ng build -prod --base-href /serversubfolder/ -aot

有什么方法可以将子脚本添加到 angular cli 中,这样我就可以制作更短的命令,这样我就不必记住所有这些参数了。即

ng build-release

哪一个等同于第一个语句?还是我暂时无法制作批处理文件?

【问题讨论】:

  • 将其添加到您的package.json?
  • 我确实看到了那里的脚本部分,并尝试搜索如何使用它并尝试通过尝试错误来解决它,但无济于事。你有一个如何在 package.json 中完成此操作的示例吗?
  • 如果您使用 Angular CLI 进行设置,它实际上会在 scripts 中包含几个使用 ng 的条目。您只需要为键选择一个名称,然后将您的命令置于该值之上。
  • 我在脚本部分添加了"build-release": "ng build --prod --base-href /mysubfolder/ -aot",但ng build-releasenpm build-release 都不起作用。我错过了什么?
  • npm run build-release - 见docs.npmjs.com/misc/scripts

标签: angular angular-cli


【解决方案1】:

在你的 package.json 文件中配置。

 "scripts": {
    "release":"ng build -prod --base-href /serversubfolder/ --aot"
  },

现在你需要输入

npm run release

【讨论】:

    猜你喜欢
    • 2017-09-02
    • 2019-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 2019-01-21
    相关资源
    最近更新 更多