diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-06 22:50:20 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-06 22:50:20 +0530 |
| commit | 8234acb45cd99fc7bcd99df7f71cac02845bb534 (patch) | |
| tree | 0110da8b5ad40b3899f57d3307292857a6a9eff7 /config/webpack/plugins/create-manifest-webpack-plugin | |
| parent | c57a9e3d9e304bd360437f8f732dbc0479376cd7 (diff) | |
| download | banglar-bhumi-utils-8234acb45cd99fc7bcd99df7f71cac02845bb534.tar.gz banglar-bhumi-utils-8234acb45cd99fc7bcd99df7f71cac02845bb534.zip | |
Added the ability to add page specific scripts.
Diffstat (limited to 'config/webpack/plugins/create-manifest-webpack-plugin')
| -rw-r--r-- | config/webpack/plugins/create-manifest-webpack-plugin/index.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index fade66d..5dac1b2 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -29,11 +29,24 @@ class CreateManifestPlugin { for (const scriptType in this.scripts) { if (Object.keys(this.scripts[scriptType]).length > 0) { - this.manifest.content_scripts.push({ - matches: ["https://banglarbhumi.gov.in/*", "http://banglarbhumi.gov.in/*"], - js: Object.keys(this.scripts[scriptType]).map(scriptName => `${scriptName}.js`), - run_at: scriptType - }); + const currentScripts = this.scripts[scriptType]; + + let paths = {}; + for (const scriptName in currentScripts) { + const scriptPath = currentScripts[scriptName]; + if (!path[scriptPath]) { + paths[scriptPath] = []; + } + paths[scriptPath].push(scriptName); + } + + for (const scriptPath in paths) { + this.manifest.content_scripts.push({ + matches: [`*://banglarbhumi.gov.in/${scriptPath}`], + js: paths[scriptPath].map(scriptName => `${scriptName}.js`), + run_at: scriptType + }); + } } } |
