在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):hillmanov/gulp-manifest开源软件地址(OpenSource Url):https://github.com/hillmanov/gulp-manifest开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-manifest
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. UsageFirst, install npm install gulp-manifest --save-dev APIParametersmanifest(options)This controls how this task (and its helpers) operate and should contain key:value pairs, see options below. options.prefixType: Add a prefix to the file paths. Useful when your files are in a different URL than the page. options.suffixType: Add a suffix to the file paths. Useful when your files have query string. options.filenameType: Set name of the Cache Manifest file. options.cacheType: Adds manually a string to the CACHE section. Needed when you have cache buster for example. options.excludeType: Exclude specific files from the Cache Manifest file. options.networkType: Adds a string to the NETWORK section. See here for more information. options.fallbackType: Adds a string to the FALLBACK section. See here for more information. options.preferOnlineType: Adds a string to the SETTINGS section, specifically the cache mode flag of the See here for more information. options.timestampType: 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 options.hashType: Adds a sha256 hash of all This will ensure that application cache invalidates whenever actual file contents change (it's recommented to set Usage Example
Output example
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. Composition of pathsSometimes your assets are served from different source directories. To route these correctly the var path = require('path');
var mergeStream = require('merge-stream');
var config = {
app: './app',
tmp: './tmp'
};
mergeStream(
gulp.src([
path.join(config.app + '*.html'),
path.join(config.app + 'assets/*.{png,svg,jpg}'),
path.join(config.app + 'js/*.js')
], {
base: config.app
}),
gulp.src([
path.join(config.tmp + 'css/*.css')
], {
base: config.tmp
})
);
.pipe(plugins.manifest({
hash: true,
preferOnline: false,
network: ['*'],
filename: 'appcache.manifest'
}))
.pipe(gulp.dest(config.tmp)); for the given file tree
will result in
Sometimes you might want to alter the way paths are passed to the plugin. The correct way will be to provide options to Say, you have a single folder named
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论