npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-manifest

v0.4.4

Published

Generate HTML5 Cache Manifest files

Downloads

1,772

Readme

grunt-manifest Build Status

Generate HTML5 Cache Manifest files.

Getting Started

This plugin requires Grunt ~0.4.5

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.

process

Type: Function Default: undefined

A function to process src files path strings before adding them on the appcache manifest.

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.

headcomment

Type: String
Default: undefined

Adds ability to append custom text to the top of the manifest file. For example, you can put your app version, so that the manifest only updates when your app version changes. Note: A '#' is added to the beginning of the text for you.

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({
  pkg: grunt.file.readJSON('package.json'),
  manifest: {
    generate: {
      options: {
        basePath: '../',
        cache: ['js/app.js', 'css/style.css'],
        network: ['http://*', 'https://*'],
        fallback: ['/ /offline.html'],
        exclude: ['js/jquery.min.js'],
        preferOnline: true,
        headcomment: " <%= pkg.name %> v<%= pkg.version %>",
        verbose: true,
        timestamp: true,
        hash: true,
        master: ['index.html'],
        process: function(path) {
          return path.substring('build/'.length);
        }
      },
      src: [
      	'build/some_files/*.html',
    	  'build/js/*.min.js',
    	  'build/css/*.css'
      ],
      dest: 'manifest.appcache'
    }
  }
});

Output example

CACHE MANIFEST
# APPNAME v1.0.0
# 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

  • 2015/01/26 - v0.4.1 - Documented process for renaming files.
  • 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.