gulp-sw-cache

0.1.5 • Public • Published

gulp-sw-cache

Add Offline Cache for WebApp. Submitted by Hom Yan

Usage

First, install gulp-sw-cache as a dev dependency

npm install gulp-sw-cache --save-dev

Then, include sw.controller.js in html, and add below to register serviceWorker.

if(condition) new SwController()

API

Parameters

sw(options)

This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.

options.versionPrefix

Type: String
Default: sw

Add a cache version prefix.

options.exclude

Type: String Array
Default: undefined

Exclude specific files from the Cache file list.

Usage Example

  gulp.task('offline', function() {
    gulp.src(path.join('src', '/**/*'))
      .pipe(sw({
        exclude: ['index.html'],
        versionPrefix: 'test'
      }))
      .pipe(gulp.dest('dist'))
  });

Package Sidebar

Install

npm i gulp-sw-cache

Weekly Downloads

5

Version

0.1.5

License

MIT

Last publish

Collaborators

  • yanzhihong23