List the files in the assets folder


#1

Hello,

I would like to know how to list the files in the assets folder. I tried with Native ionic file, but I can not access it. (On IOS)

this.file
.checkDir(this.file.applicationDirectory + ‘www/assets/’, ‘data’)
.then(result => {
console.log(result);
}).catch((error) => {
console.log('error ’ + JSON.stringify(error));
});

He tells me that the file does not exist.

thank you,
Regards,


#2

@angular/service-worker creates a control file (i.e., www/ngsw.json) that contains a list of the files in your assets directory:

For example:

{
  "configVersion": 1,
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "Brew",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "urls": [
        "/index.html",
        "/manifest.json",
        "/build/0.js",
        "/build/1.js",
        "/build/10.js",
        "/build/2.js",
        
        ...
        
        "/build/main.css",
        "/build/main.js",
        "/build/polyfills.js",
        "/build/sw-toolbox.js",
        "/build/vendor.js"
      ],
      "patterns": []
    },
    {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "urls": [
        "/assets/fonts/noto-sans-bold.ttf"
        "/assets/fonts/noto-sans-bold.woff",
        "/assets/fonts/noto-sans-regular.ttf",
        "/assets/fonts/noto-sans-regular.woff",
        "/assets/fonts/noto-sans.scss",
        
        ...
        
        "/assets/icons/android-chrome-192x192.png",
        "/assets/icons/android-chrome-512x512.png",
        "/assets/icons/apple-touch-icon.png",
        "/assets/icons/favicon-16x16.png",
        "/assets/icons/favicon-32x32.png",
        "/assets/icons/favicon.ico",
        "/assets/icons/icon-1200x1200.png",
        "/assets/icons/icon-128x128.png",
        "/assets/icons/icon-144x144.png",
        "/assets/icons/icon-152x152.png",
        "/assets/icons/icon-192x192.png",
        "/assets/icons/icon-384x384.png",
        "/assets/icons/icon-512x512.png",
        "/assets/icons/icon-72x72.png",
        "/assets/icons/icon-96x96.png",
        "/assets/icons/mstile-150x150.png",
        "/assets/icons/safari-pinned-tab.svg"
      ],
      "patterns": []
    }
  ],
  "dataGroups": [],
  "hashTable": {
    "/build/0.js": "52a2e26203d073ee2e8704330b07f1cecf0d513e",
    "/build/1.js": "ed5cd1ba257c919835e853389ba43035aed20a4d",
    "/build/10.js": "71f52bb683be89d2f12caaf1d79b895d10d35a76",
    "/build/2.js": "e03b904da18dde1fd704d739b2c1ba2acb5879bc",
    
    ...
    
  }
}

See: https://robferguson.org/blog/2018/04/16/0ptimising-the-performance-of-an-ionic-pwa-part-1/


#3

Perfect, thank you I will test this