Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

mschipperheyn/razzle-plugin-offline

Repository files navigation

Razzle Plugin Offline

Adds a NekR/offline-plugin serviceworker to your Razzle implementation.

Installation

yarn add razzle-plugin-offline

Configuration

Edit or create razzle.config.js in your project root.

// razzle.config.js
module.exports = {
  plugins: ['offline'],
};

Add serviceWorker to client

At the bottom of your src/client.js add

if (process.env.NODE_ENV === 'production') {
  require('razzle-plugin-offline/lib/serviceWorker')();
}

Adding client side serviceWorker options

Options are optional and should be based on NekR/offline-plugin

if (process.env.NODE_ENV === 'production') {
  const options = {
      // my options
  };
  require('razzle-plugin-offline/lib/serviceWorker')(options);
}

Adding server side webpack plugin options

// razzle.config.js
module.exports = {
  plugins: [{
      name:'offline',
      options: {
          autoUpdate: true
      }
  }],
};

License

MIT

About

Implements a serviceworker for Razzle using offline-plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published