简体   繁体   中英

Angular-cli specifying file names for production environment

Angular is generating random names for the files when running ng build --prod . Is there a way to specify the names we want? We are using angular-cli . We really need this as our angular application is embedded inside a CMS platform.

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. 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

Now it is possible by setting up namedChunks: true in the file angular.json . It will leave generated readable name for chanks, same as you see when starting a project by 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 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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