gatsby-plugin-ipfs icon indicating copy to clipboard operation
gatsby-plugin-ipfs copied to clipboard

Remove prefix in manifest file (manifest.webmanifest)

Open jsonsivar opened this issue 4 years ago • 1 comments

Currently the manifest file is not getting the prefix replaced. I think it's safe just to remove it since it's already relative. Looking at this line, it looks like if we add a special case for a .webmanifest file that removes it the URLs for the icons should be fine.

Let me know if that makes sense, I can try creating a PR for it if you think that's the right direction.

jsonsivar avatar Feb 25 '20 01:02 jsonsivar

I added this snippet in a local project and it seemed to have cleared the manifest file:

exports.onPostBuild = async ({ reporter }) => {
    // replace prefix paths for manifest file   
    const path = 'public/manifest.webmanifest';
    const buffer = await readFileAsync(path);
    let contents = buffer.toString();

    if (!contents.includes('__GATSBY_IPFS_PATH_PREFIX__')) {
        return;
    }

    contents = contents
    .replace("\"/__GATSBY_IPFS_PATH_PREFIX__\"", "\"/\"")
    .replace(/\/__GATSBY_IPFS_PATH_PREFIX__\//g, "/");

    await writeFileAsync(path, contents);
}

jsonsivar avatar Feb 25 '20 01:02 jsonsivar