rememberify

2019-07-11 admin

rememberify是什么

什么是rememberify,File cache plugin for browserify. (Basically, watchify without the file watch mode!)

rememberify使用教程帮助文档

rememberify NPM version Build status

File cache plugin for browserify.

Basically, this is just watchify without the file watch mode! Use this plugin if you’re already listening for file system events via something like gulp-watch or chokidar, and only want the caching mechanism of watchify for fast builds.

Installation

Install the package with NPM:

$ npm install rememberify

Usage

Register the plugin with a browserify instance:

import browserify from "browserify";
import rememberify from "rememberify";

let b = browserify({ cache: {} }).plugin(rememberify);

When you receive a file system event, simply invalidate the cache:

rememberify.forget(b, file);

Tip

Using rememberify with gulp-watch is easy. Here’s a full example:

import gulp from "gulp";
import watch from "gulp-watch";
import source from "vinyl-source-stream";
import browserify from "browserify";
import rememberify from "rememberify";

let b = browserify("./lib/app.js", { cache: {} }).plugin(rememberify);

gulp.task("build", () => {
  return b.bundle().pipe(source("bundle.js")).pipe(gulp.dest("dist"));
});

gulp.task("watch", ["build"], () => {
  return watch("lib/**/*.js", vinyl => {
    rememberify.forget(b, vinyl.path);
    gulp.start("build");
  });
});

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69449.html

文章标题:rememberify

回到顶部