aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/plugins/create-rules-webpack-plugin.js
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-13 23:32:26 +0530
committerGitHub <noreply@github.com>2026-07-13 23:32:26 +0530
commitce401d03e75bcbfd1cdfa963954e0807219fb80d (patch)
tree52a813c1705a952312c20c328b00fa845a3453f9 /config/webpack/plugins/create-rules-webpack-plugin.js
parent98e7019c61ea0ffe344ef7ce809d38d62254a9fc (diff)
parentdfba7ff6fff7bde33b40a343a2318b35c429b40f (diff)
downloadbanglar-bhumi-utils-ce401d03e75bcbfd1cdfa963954e0807219fb80d.tar.gz
banglar-bhumi-utils-ce401d03e75bcbfd1cdfa963954e0807219fb80d.zip
Merge pull request #6 from arpitchakladar/adding-documentation-comments
Adding documentation comments
Diffstat (limited to 'config/webpack/plugins/create-rules-webpack-plugin.js')
-rw-r--r--config/webpack/plugins/create-rules-webpack-plugin.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/config/webpack/plugins/create-rules-webpack-plugin.js b/config/webpack/plugins/create-rules-webpack-plugin.js
index 5573ddf..ce2fbef 100644
--- a/config/webpack/plugins/create-rules-webpack-plugin.js
+++ b/config/webpack/plugins/create-rules-webpack-plugin.js
@@ -1,16 +1,26 @@
-import path from "path";
import fs from "fs";
+import path from "path";
+
import webpack from "webpack";
+/**
+ * Webpack plugin that reads all JSON rule files from `src/rules/`,
+ * assigns sequential IDs to each rule, and emits a single `rules.json`
+ * asset used by `declarativeNetRequest`.
+ */
class CreateRulesPlugin {
+ /**
+ * @param {import("webpack").Compiler} compiler
+ * @returns {void}
+ */
apply(compiler) {
- compiler.hooks.compilation.tap("CreateRulesPlugin", compilation => {
+ compiler.hooks.compilation.tap("CreateRulesPlugin", (compilation) => {
compilation.hooks.processAssets.tap(
{
name: "CreateRulesPlugin",
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
},
- assets => {
+ (_assets) => {
const ruleFileNames = fs.readdirSync(path.resolve(SOURCE_DIR, "rules"));
const rules = [];
let ruleId = 1;