Skip to content

easy-webpack/config-offline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@easy-webpack/config-offline

Enable offline capability of your webapp using ServiceWorker or AppCache.

This config use offline-plugin to achieve generation of ServiceWorker and AppCache files.

Installation

npm install --save-dev @easy-webpack/config-offline

easy-webpack is also required.

Usage

// webpack.config.js
const generateConfig = require('@easy-webpack/core').generateConfig;

const baseConfig = { ... }; // project-specific config like the entry file

const offlineConfig = {
  caches: {
    main: [':rest:'],
    additional: [':externals:'],
    optional: ['*.chunk.js']
  },
  ServiceWorker: {
    events: true
  },
  AppCache: {
    caches: ['main', 'additional', 'optional']
  }
}

module.exports = generateConfig(
  baseConfig,
  
  require('@easy-webpack/config-offline')
    ({ options: offlineConfig })
);

// Any client JS file, typically main entry
require('offline-plugin/runtime').install();

// This config will generate a service worker and app cache config in output path 

It is recommended to put config-offline at the end of webpack config chain.

Options

options

Type: Object Default: {}

This is identical to options in offline-plugin. Please check their documentation on how to configure it.

Related tutorials