Skip to content

Commit 3eda621

Browse files
committed
docs(plugin): add context and missing dependencies example
1 parent 2426064 commit 3eda621

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/content/contribute/writing-a-plugin.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ that webpack does not track by default, you must tell webpack to watch them.
342342

343343
The `compilation.fileDependencies` set allows you to add such files.
344344

345+
You can also watch directories and even files that do not yet exist:
346+
347+
- `compilation.contextDependencies` → for directories
348+
- `compilation.missingDependencies` → for future files
349+
345350
```js
346351
const path = require("node:path");
347352

@@ -352,6 +357,14 @@ class TemplateWatchPlugin {
352357

353358
// Ensure webpack watches this file
354359
compilation.fileDependencies.add(templatePath);
360+
361+
// Watch a directory (context dependency)
362+
const templatesDir = path.resolve(__dirname, "templates");
363+
compilation.contextDependencies.add(templatesDir);
364+
365+
// Example: mark a missing dependency
366+
const missingFile = path.resolve(__dirname, "missing-file.txt");
367+
compilation.missingDependencies.add(missingFile);
355368
});
356369
}
357370
}

src/utilities/cn.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
21
import { clsx } from "clsx";
32
import { twMerge } from "tailwind-merge";
43

0 commit comments

Comments
 (0)