@lcdp/offline-plugin

5.1.1 • Public • Published

Forked from NekR offline-plugin

offline-plugin for webpack


This plugin is intended to provide an offline experience for webpack projects. It uses ServiceWorker, and AppCache as a fallback under the hood. Simply include this plugin in your webpack.config, and the accompanying runtime in your client script, and your project will become offline ready by caching all (or some) of the webpack output assets.

If you are looking for the original v5 from NekR offline-plugin we have stored it on v5 branch.

Install

npm install @lcdp/offline-plugin [--save-dev]

Setup

First, instantiate the plugin in your webpack.config:

// webpack.config.js example

var OfflinePlugin = require('@lcdp/offline-plugin');

module.exports = {
  // ...

  plugins: [
    // ... other plugins
    // it's always better if OfflinePlugin is the last plugin added
    new OfflinePlugin()
  ]
  // ...
}

(and optionally configure with options)

Then, add the runtime into your entry file (typically main entry):

require('@lcdp/offline-plugin/runtime').install();

ES6/Babel/TypeScript

import * as OfflinePluginRuntime from '@lcdp/offline-plugin/runtime';
OfflinePluginRuntime.install();

For more details of usage with TypeScript see here

offline-plugin isn't working?

ℹ️ Troubleshooting | FAQ

Docs

Examples

Articles

Options

All options are optional and offline-plugin can be used without specifying them.

See all available options here.

Who is using offline-plugin

Projects

PWAs

If you are using offline-plugin, feel free to submit a PR to add your project to this list.

Contribution

See CONTRIBUTING

License

MIT

CHANGELOG

CHANGELOG

Package Sidebar

Install

npm i @lcdp/offline-plugin

Weekly Downloads

3,008

Version

5.1.1

License

MIT

Unpacked Size

101 kB

Total Files

22

Last publish

Collaborators

  • gery-lcdp