Search code examples
angularangular-cliservice-workerhtml5-appcache

Is it possible to auto generate HTML5-AppCache Manifest files?


I am building a web app using Angular 4 with Angular CLI. I am trying to implement App-cache for IE browsers since it does not support service workers, but the issue i'm running into is that the files static files generated by the build have a a hash code associated with them so i am unable to explicitly list the files I want to cache for App-cache. Is there any way to do this?


Solution

  • There is a way to remove hashing from the file name in angular cli.

    You can remove hash part with output-hashing option on ng build --prod --output-hashing none

    output-hashing --output-hashing (short cut: -oh)
    possible values: none, all, media, bundles
    

    console output

    xxxx$ ng build --prod --output-hashing none
    Date: 2017-09-21T14:52:13.362Z                                                          
    Hash: 115fd3ecef82add2dac2
    Time: 6415ms
    chunk {0} polyfills.bundle.js (polyfills) 64.1 kB {4} [initial] [rendered]
    chunk {1} main.bundle.js (main) 5.14 kB {3} [initial] [rendered]
    chunk {2} styles.bundle.css (styles) 0 bytes {4} [initial] [rendered]
    chunk {3} vendor.bundle.js (vendor) 307 kB [initial] [rendered]
    chunk {4} inline.bundle.js (inline) 1.36 kB [entry] [rendered]
    xxxx$ ls
    README.md       e2e         node_modules        package.json        src         tslint.json
    dist            karma.conf.js       package-lock.json   protractor.conf.js  tsconfig.json
    xxxx$ cd  dist
    xxxx$ ls
    3rdpartylicenses.txt    favicon.ico     index.html      inline.bundle.js    main.bundle.js      polyfills.bundle.js styles.bundle.css   vendor.bundle.js
    xxxx$ ls -lart
    total 784
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users  306976 Sep 21 10:52 vendor.bundle.js
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users       0 Sep 21 10:52 styles.bundle.css
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users   64051 Sep 21 10:52 polyfills.bundle.js
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users    5141 Sep 21 10:52 main.bundle.js
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users    1363 Sep 21 10:52 inline.bundle.js
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users     568 Sep 21 10:52 index.html
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users    5430 Sep 21 10:52 favicon.ico
    -rw-r--r--   1 xxxxxx  NASDCORP\Domain Users    3415 Sep 21 10:52 3rdpartylicenses.txt
    drwxr-xr-x  17 xxxxxx  NASDCORP\Domain Users     578 Sep 21 10:52 ..
    drwxr-xr-x  10 xxxxxx  NASDCORP\Domain Users     340 Sep 21 10:52 .
    

    angular and cli version:

    xxxx$ ng -v
    @angular/cli: 1.4.2
    node: 8.5.0
    os: darwin x64
    @angular/animations: 4.4.3
    @angular/common: 4.4.3
    @angular/compiler: 4.4.3
    @angular/core: 4.4.3
    @angular/forms: 4.4.3
    @angular/http: 4.4.3
    @angular/platform-browser: 4.4.3
    @angular/platform-browser-dynamic: 4.4.3
    @angular/router: 4.4.3
    @angular/cli: 1.4.2
    @angular/compiler-cli: 4.4.3
    @angular/language-service: 4.4.3
    typescript: 2.3.4