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

Latest webpack adds /auto/ to folder? #143

Closed FloodGames closed 3 years ago

FloodGames commented 3 years ago

The directory /auto/ is unintentionally added below to my webpack (v5.2.0) distribution.

index.html <link rel="manifest" href="auto/manifest.webmanifest" crossorigin="use-credentials"/>

manifest.webmanifest "src": "auto/icons/android/icon_512x512.a621029042a759e434c558ca6e5d11fe.png",

webpack config:

     new WebpackPwaManifest({
        filename: "manifest.webmanifest",
        orientation: "landscape",
        display: "fullscreen",
        start_url: "/",
        crossorigin: "use-credentials", //mega important to reload newest version of index.html !
        inject: true, //put icons in index.html
        fingerprints: true,
        ios: true,
        publicPath: null,
        includeDirectory: true,
        background_color: "#01579b",
        theme_color: "#01579b",
        icons: [
          {
            src: path.resolve("public/assets/pwa/icon.png"), //ios icon
            sizes: [120, 152, 167, 180, 1024],
            destination: path.join("icons", "ios"),
            ios: true,
          },
          {
            src: path.resolve("public/assets/pwa/icon.png"), //android icon
            size: 1024,
            destination: path.join("icons", "ios"),
            ios: "startup",
          },
          {
            src: path.resolve("public/assets/pwa/icon.png"), //android icon
            sizes: [36, 48, 72, 96, 144, 192, 512],
            destination: path.join("icons", "android"),
          },
        ],
      }),
FloodGames commented 3 years ago

Webpack 5.3.0 didn't fix it.

I also notice my serviceworker.js has the same problem: auto../assets/

FloodGames commented 3 years ago

Adding PublicPath fixed the manifest reference in .html and the manifest itself.

    output: {
      filename: "[name].[contenthash].js",
      path: path.resolve("dist", "public", "scripts"), //, "scripts"
      publicPath: "/",
    },

Adding modifyURLPrefix fixed my serviceworker.js

       new WorkboxPlugin.InjectManifest({
        maximumFileSizeToCacheInBytes: 10000000, //MUSIC.bank is 7.71 MB, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.
        swSrc: "./src/client/serviceworker/serviceworker.js", //"./public/assets/serviceworker.js", //path.resolve(__dirname, "public/assets/"),
        mode: "production",
        modifyURLPrefix: {
          "/../<SOMETHING>/": "/static/",
        },
      }),
b7s9 commented 3 years ago

thank you! i had the same issue, and setting publicPath: "/" also got rid of the auto/ prefix for me