arthurbergmz / webpack-pwa-manifest

Progressive Web App Manifest Generator for Webpack, with auto icon resizing and fingerprinting support.
MIT License
514 stars 94 forks source link

"auto" being appended to the generated manifest's icon src attributes #149

Open DKulan opened 3 years ago

DKulan commented 3 years ago

Trying to generate a manifest based on these options:

new WebpackPwaManifest({
            name: "Food Event",
            short_name: "Foodies",
            description: "An app that allows you to view upcoming food events.",
            start_url: "../index.html",
            background_color: "#01579b",
            theme_color: "#ffffff",
            fingerprints: false,
            inject: false,
            icons: [{
                src: path.resolve("assets/img/icons/icon-512x512.png"),
                sizes: [96, 128, 192, 256, 384, 512],
                destination: path.join("assets", "icons")
            }]
        })

but I get "auto" appending in the icons src attribute for some reason:

{
  "icons": [
    {
      "src": "auto/assets/icons/icon_512x512.png",
      "sizes": "512x512",
      "type": "image/png"
    },
    {
      "src": "auto/assets/icons/icon_384x384.png",
      "sizes": "384x384",
      "type": "image/png"
    },
    {
      "src": "auto/assets/icons/icon_256x256.png",
      "sizes": "256x256",
      "type": "image/png"
    },
    {
      "src": "auto/assets/icons/icon_192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "auto/assets/icons/icon_128x128.png",
      "sizes": "128x128",
      "type": "image/png"
    },
    {
      "src": "auto/assets/icons/icon_96x96.png",
      "sizes": "96x96",
      "type": "image/png"
    }
  ],
  "name": "Food Event",
  "short_name": "Foodies",
  "orientation": "portrait",
  "display": "standalone",
  "start_url": "../index.html",
  "description": "An app that allows you to view upcoming food events.",
  "background_color": "#01579b",
  "theme_color": "#ffffff"
}
Abachouch commented 3 years ago

just add publicPath: '/', , i think its publicPath: 'auto', by default

 new WebpackPwaManifest({
   publicPath: '/' ,
   // the rest of code
})
AlexTogar commented 3 years ago

just add publicPath: '/', , i think its publicPath: 'auto', by default

 new WebpackPwaManifest({
   publicPath: '/' ,
   // the rest of code
})

Thanks, I've added publicPath: '.' and everything works now :)

SMKrizan commented 3 years ago

...this resolved my issue, too. Many thanks!

Craig5117 commented 3 years ago

FYI, when I tried the above solution, it fixed the problem on localhost, but when I pushed to GitHub, I had a new issue with the GitHub pages version. On the GitHub deployed app, the browser took the "/" as referring to the root, and it confused dist/assets with /assets at the root level. The solution that fixed this was to replace the publicPath setting with "./". The build output for my manifest looked like this "./assets/icons/icon_512x512.png". Works the same on localhost and the live deployed version now.