metalsmith-changed
Only process files that have changed.
metalsmith-changed will write a ctimes json-file to your build
-folder in order to keep track of changed files.
Must be used with metalsmith.clean(false)
, .clean(true)
(the default) disables metalsmith-changed and all files are passed on to the next plugin.
metalsmith-changed can also be disabled with force: true
and individual files can be ignored (always build) with forcePattern
.
example
var Metalsmith = ;var changed = ; ... // more plugins ;
Which is useful when watching files and livereloading:
const Metalsmith = ;const changed = ;const livereload = ;const nodeStatic = ;const watch = ;const open = ; const DIR = __dirname + '/test/fixtures/'; /** * Build with metalsmith. */const build = { console; // .use(expensivePlugin()) // ie markdown -> html ;}; /** * Serve files. */var serve = DIR + 'build';; /** * Watch files. */;// watch(DIR + 'templates/**/*', build(true)); // force build of all files /** * Open browser. */;
As ctimes are persisted to disk, this works nice with cli tools like watch run too.
forcePattern
If the option forcePattern
is defined, files matching the pattern(s) will not
be removed from building even if the file has not changed. forcePattern
should
be a string or an array of strings.
micromatch is used for matching the files.
Example:
... // more plugins ;
default options
metalsmith-changed-ctimes.json
metalsmith-changed-ctimes.json
is written to your build
folder upon every build. metalsmith-changed
takes ctimes from files[n].stats.ctime
, so if a plugin creates files with .stats.ctime
, metalsmith-changed
can be used with it.
Files without stats.ctime
are always built.
develop
npm build # babel npm testDEBUG=metalsmith-changed npm test # test with debug output
release
npm version patch|minor|majornpm publish