Giter VIP home page Giter VIP logo

gulp-manifest's Introduction

gulp-manifest

Generate HTML5 Cache Manifest files. Submitted by Scott Hillman.

Big thanks to Gunther Brunner for writing the grunt-manifest plugin. This plugin was heavily influenced by his great work.

Visit the HTML 5 Guide to AppCache for more information on Cache Manifest files.

Usage

First, install gulp-manifest as a dev dependency

npm install gulp-manifest --save-dev

API

Parameters

manifest(options)

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

options.prefix

Type: String
Default: undefined

Add a prefix to the file paths. Useful when your files are in a different URL than the page.

options.basePath

Type: String
Default: undefined

Set a basepath for the files. Useful when the files are not served from the toplevel directory.

options.filename

Type: String
Default: "app.manifest"

Set name of the Cache Manifest file.

options.cache

Type: String
Default: undefined

Adds manually a string to the CACHE section. Needed when you have cache buster for example.

options.exclude

Type: String Array
Default: undefined

Exclude specific files from the Cache Manifest file.

options.network

Type: String Array
Default: "*" (By default, an online whitelist wildcard flag is added)

Adds a string to the NETWORK section.

See here for more information.

options.fallback

Type: String Array
Default: undefined

Adds a string to the FALLBACK section.

See here for more information.

options.preferOnline

Type: Boolean
Default: undefined

Adds a string to the SETTINGS section, specifically the cache mode flag of the prefer-online state.

See here for more information.

options.timestamp

Type: Boolean
Default: true

Adds a timestamp as a comment for easy versioning.

Note: timestamp will invalidate application cache whenever cache manifest is rebuilt, even if contents of files in src have not changed.

options.hash

Type: Boolean
Default: false

Adds a sha256 hash of all src files (actual contents) as a comment.

This will ensure that application cache invalidates whenever actual file contents change (it's recommented to set timestamp to false when hash is used).

Usage Example

gulp.task('manifest', function(){
  gulp.src(['build/*'])
    .pipe(manifest({
      hash: true,
      preferOnline: true,
      network: ['*'],
      filename: 'app.manifest',
      exclude: 'app.manifest'
     }))
    .pipe(gulp.dest('build'));
});

Output example

CACHE MANIFEST

CACHE:
js/app.js
css/style
css/style.css
js/zepto.min.js
js/script.js
some_files/index.html
some_files/about.html

NETWORK:
*

# hash: 76f0ef591f999871e1dbdf6d5064d1276d80846feeef6b556f74ad87b44ca16a

You do need to be fully aware of standard browser caching. If the files in CACHE are in the network cache, they won't actually update, since the network cache will spit back the same file to the application cache. Therefore, it's recommended to add a hash to the filenames's, akin to rails or yeoman. See here why query strings are not recommended.

gulp-manifest's People

Contributors

hillmanov avatar satya164 avatar hbbbs avatar shuhei avatar willfarrell avatar pgilad avatar mariocasciaro avatar orkon avatar scottrain avatar gronke avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.