apw

asset-precache-webpack-plugin

manage your assets loading

Showing:

Popularity

Downloads/wk

2

GitHub Stars

2

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

6.9KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Asset Precache Webpack Plugin

Installation

npm:

npm install asset-precache-webpack-plugin --save-dev

Useage

  • webpack config
var AssetPrecachePlugin=require('asset-precache-webpack-plugin');
var webpackConfig={
    ...
    plugins:[new AssetPrecachePlugin({
        key:'__precacher',
        filename:'precache.[chunkhash:8].js',
    })]
    ...
}
  • runtime code
window.__precacher
    .filter({key:'type',reg:/^(image|js)$/})
    .load()

Configuration

  • filename: Relative path to webpack output path. Support hash, chunkhash. e.g. precache.[chunkhash:8].js
  • key: entry of precache module in window. e.g. '__precacher', use window.precacher runtime.

Run

  • Get root obj by key which is specified in webpack config
var precacher=window.__precacher;
  • Use filter method to decide which asset not cache. Filter has one parameter with two kind of format: obj or function.
var resource=precacher.filter({key:'type',reg:/^(image|js)$/})
  • Use load method to precache assets
resource.load()

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100