无需散列的 Angular 构建文件命名

问题描述 投票:0回答:2

当我进行正常构建时:

构建

我得到文件:

Initial Chunk Files           | Names         |      Size    
main.67a03e810140e0bd.js      | main          | 132.08 kB    
polyfills.881fa69e872290d9.js | polyfills     |  36.19 kB    
runtime.3b2ac8c1adcf7f83.js   | runtime       |   1.04 kB
styles.ef46db3751d8e999.css   | styles        |   0 bytes

如何删除“.67a03e810140e0bd”。等等?

PS。如果有的话,它是在 .NET 应用程序中制作的

angular-cli
2个回答
6
投票

您可以使用

--output-hashing
选项,因此您可以使用:

进行构建
ng build --output-hashing=none

话虽这么说,大多数时候您实际上希望对文件名进行哈希处理,以便您的用户浏览器在您发布新版本时不会使用文件的旧缓存版本。


0
投票

在中设置“outputHashing”:“none” Angular.json

{
  "projects": {
    "myApp": {
      "architect": {
        "build": {
          "configurations": {
             "production":{
                "outputHashing": "none"
     

另一种选择是将参数传递给 cli:

ng build --output-hashing=none
© www.soinside.com 2019 - 2024. All rights reserved.