简体   繁体   English

Angular-cli 为生产环境指定文件名

[英]Angular-cli specifying file names for production environment

Angular is generating random names for the files when running ng build --prod . Angular 在运行ng build --prod时为文件生成随机名称。 Is there a way to specify the names we want?有没有办法指定我们想要的名字? We are using angular-cli .我们正在使用angular-cli We really need this as our angular application is embedded inside a CMS platform.我们确实需要它,因为我们的 angular 应用程序嵌入在 CMS 平台中。

I think you can. 我想你可以。

  • use the standard names like inline.bundle.js vendor.bundle.js , main.bundle.js this are enable in dev mode, but if you want to have the names in prod mode. 使用标准名称,如inline.bundle.js vendor.bundle.js,main.bundle.js这是在开发模式下启用,但如果你想在prod模式下使用名称。 In your case, 在你的情况下,

     ng build --prod 

    you can use the following flag to avoid the hashing 您可以使用以下标志来避免散列

      ng build --prod --output-hashing none 

    more info https://github.com/angular/angular-cli/wiki/build 更多信息https://github.com/angular/angular-cli/wiki/build

Now it is possible by setting up namedChunks: true in the file angular.json .现在可以通过在文件angular.json设置namedChunks: trueangular.json It will leave generated readable name for chanks, same as you see when starting a project by ng start它将为 chanks 留下生成的可读名称,与您在通过ng start项目时看到的相同

ng build FooBar --out-hasing none will do what you want but if you dont want to keep typing "--out-hasing none" each time you build, you can set the "outputHasing" property to "none" right in the angular.json file ng build FooBar --out-hasing none 会做你想做的,但如果你不想每次构建时都输入“--out-hasing none”,你可以将“outputHasing”属性设置为“none” angular.json 文件在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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