gatsby-plugin-ipfs

2.0.2 • Public • Published

gatsby-plugin-ipfs

NPM version Downloads Dependency status Dev Dependency status Greenkeeper badge

Adds support for deploying Gatsby websites to IPFS by ensuring that assets are relative.

Installation

$ npm install --save gatsby-plugin-ipfs

Usage

Set prefixPath to __GATSBY_IPFS_PATH_PREFIX__ and include the plugin in your gatsby-config.js file:

module.exports = {
    pathPrefix: '__GATSBY_IPFS_PATH_PREFIX__',
    plugins: [
        'gatsby-plugin-ipfs',
    ]
}

And now, simply build the project with npm run build -- --prefix-paths. Better yet, set it by default in your package.json:

"scripts"{
  "build": "gatsby build --prefix-paths"
},

But how?

It turns out the Gatsby doesn't support relative paths. But I didn't gave up and came up with smart and ugly hacks to do so:

  • Adds a post-build step that iterates over files and transforms every __GATSBY_IPFS_PATH_PREFIX__ occurrence
  • Adds a very small code snippet to every HTML page that defines the __GATSBY_IPFS_PATH_PREFIX__ global based on the browser location

License

MIT License

/gatsby-plugin-ipfs/

    Package Sidebar

    Install

    npm i gatsby-plugin-ipfs

    Weekly Downloads

    7

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    11.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • tiagodinis
    • moxyhq
    • filipediasf
    • satazor
    • marcooliveira
    • acostalima
    • andregoncalvesdev
    • parkan
    • willmhowes