GithubHelp home page GithubHelp logo

grunt-manifest's Introduction

grunt-manifest Build Status

Generate HTML5 Cache Manifest files.

IMPORTANT (!):

Repository looking for mantainer currently.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-manifest --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-manifest');

HTML5 Cache Manifest task

Run this task with the grunt manifest command.

Visit the Appcache Facts for more information on Cache Manifest files.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Parameters

options

Type: Object
Default: {}

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

src

Type: String Array
Default: undefined

Sets the input files.

dest

Type: String Default manifest.appcache

Sets the name of the Cache Manifest file. Remember that .appcache is now the W3C recommended file extension.

Options

basePath

Type: String Default: undefined

Sets the base path for input files. It's recommended to set this.

cache

Type: String Default: undefined

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

exclude

Type: String Array Default: undefined

Exclude specific files from the Cache Manifest file.

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.

fallback

Type: String Array Default: undefined

Adds a string to the FALLBACK section.

See here for more information.

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.

verbose

Type: Boolean Default: true

Adds a meta "copyright" comment.

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.

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).

master

Type: String Array Default: undefined

Hashes master html files (used with hash). Paths must be relative to the 'basePath'. This is useful when there are multiple html pages using one cache manifest and you don't want to explicitly include those pages in the manifest.

Config Example

// Project configuration
grunt.initConfig({
  manifest: {
    generate: {
      options: {
        basePath: '../',
        cache: ['js/app.js', 'css/style.css'],
        network: ['http://*', 'https://*'],
        fallback: ['/ /offline.html'],
        exclude: ['js/jquery.min.js'],
        preferOnline: true,
        verbose: true,
        timestamp: true,
        hash: true,
        master: ['index.html']
      },
      src: [
      	'some_files/*.html',
    	  'js/*.min.js',
    	  'css/*.css'
      ],
      dest: 'manifest.appcache'
    }
  }
});

Output example

CACHE MANIFEST
# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator
# Time: Mon Jan 01 2155 22:23:24 GMT+0900 (JST)

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.

Release History

  • 2012/10/23 - v0.4.0 - Changed package and repository name to grunt-manifest.
  • 2012/10/23 - v0.3.0 - Upgraded to Grunt 0.4. Fixed dependencies. Fixed basePath.
  • 2012/10/23 - v0.2.1 - Added possibility to manually specify "CACHE:" files. Made comments optional.
  • 2012/09/28 - v0.2.0 - Refactored from grunt-contrib into individual repo.

grunt-manifest's People

Contributors

adrianheine avatar alefteris avatar demands avatar devinrhode2 avatar fhemberger avatar garaboncias avatar gunta avatar muxa avatar oscarsanguino avatar saulhardman avatar tm-minty 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.