用于散列资产和资源文件夹的文件名的 Angular 构建过程 [英] Angular Build Process to hash the File Name of Asset and Resource Folders

查看:16
本文介绍了用于散列资产和资源文件夹的文件名的 Angular 构建过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Angular 4.4.6 应用程序,我使用 Angular CLI 1.0.1 构建它.

I have an Angular 4.4.6 application and I build this using Angular CLI 1.0.1.

我遇到的问题是,除了inline.bundle.jsmain.bundlepolyfills.bundle.jsstyles.bundle.jsvendor.bundle.js 文件名、assets"中的所有其他文件名;和资源";当我构建应用程序时,文件夹不会被散列.

The problem I have is, apart from inline.bundle.js, main.bundle, polyfills.bundle.js, styles.bundle.js, vendor.bundle.js files names, all other File Names in "assets" and "resources" folder are NOT hashed when I build the application.

由于文件名未经过哈希处理,这些文件的请求 URL 保持不变,因此浏览器会自行从缓存中获取这些文件,并且不会反映新的更改.

Since the file name is not hashed the request URLs for these files remain same and hence the browsers takes these files from cache it self and new changes are not reflecting.

有人可以帮助我如何散列资产"的所有文件名吗?和资源"文件夹以及避免缓存这些文件?

Can somebody help how I can hash all the file names of "assets" and "resources" folders as well to avoid caching of these files ?

Build Command: ng build --prod --aot --no-sourcemap --output-hash=all

操作系统:Windows 10

OS: Windows 10

谢谢

推荐答案

只需将 outputHashing 设置为all"即可在 angular.json 文件

Simply set outputHashing to "all" in the angular.json file

"projects": {
   ...
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
           ...
          },
          "configurations": {
            "production": {
             ...
              "outputHashing": "all",
...

这篇关于用于散列资产和资源文件夹的文件名的 Angular 构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆