aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-09 14:40:38 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-09 14:40:38 +0530
commitf18102cdaf55acbf3bae7a7290c9158d21abc7eb (patch)
treeab449b69e8b5684570c108a9dccbad78c51971c7 /config
parentb6046c22deb4d00ca07a9eedd27c7e8eae064518 (diff)
downloadbanglar-bhumi-utils-f18102cdaf55acbf3bae7a7290c9158d21abc7eb.tar.gz
banglar-bhumi-utils-f18102cdaf55acbf3bae7a7290c9158d21abc7eb.zip
Using path hash for seperating scripts for different paths
Diffstat (limited to 'config')
-rw-r--r--config/webpack.config.js3
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/index.js3
-rw-r--r--config/webpack/utils/file-name-hash.js3
3 files changed, 7 insertions, 2 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index d90be46..90274f6 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -10,6 +10,7 @@ const SanitizeScriptsImportPlugin = require(path.resolve(process.env.CONFIG_DIR,
const InjectScriptPlugin = require(path.resolve(process.env.CONFIG_DIR, "webpack/plugins/inject-script-webpack-plugin"));
const { inlineJavascript } = require(path.resolve(process.env.CONFIG_DIR, "webpack/utils/inline-javascript"));
const { getScriptRuntimeFromType } = require(path.resolve(process.env.CONFIG_DIR, "webpack/utils/script-runtime"));
+const { getFileNameHash } = require(path.resolve(process.env.CONFIG_DIR, "webpack/utils/file-name-hash"));
const scripts = require(path.resolve(process.env.SOURCE_DIR, "scripts.json"));
@@ -38,7 +39,7 @@ for (const scriptRuntime in allScripts) {
name: scriptRuntime,
mode: "production",
output: {
- filename: `scripts/${scriptRuntime}.js`
+ filename: `scripts/${getFileNameHash(Object.values(allScripts[scriptRuntime])[0])}/${scriptRuntime}.js`
},
resolve: {
extensions: ["", ".ts", ".js"],
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
index 5729ed9..fcfe689 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
@@ -3,6 +3,7 @@ const path = require("path");
const { version } = require(path.resolve(process.env.ROOT_DIR, "package.json"));
const { getScriptRuntimeFromType } = require(path.resolve(process.env.CONFIG_DIR, "webpack/utils/script-runtime"));
+const { getFileNameHash } = require(path.resolve(process.env.CONFIG_DIR, "webpack/utils/file-name-hash"));
class CreateManifestPlugin {
constructor({ scripts }) {
@@ -42,7 +43,7 @@ class CreateManifestPlugin {
for (const scriptPath in paths) {
this.manifest.content_scripts.push({
matches: [`*://banglarbhumi.gov.in/${scriptPath}`],
- js: [`scripts/${scriptRuntime}.js`],
+ js: [`scripts/${getFileNameHash(scriptPath)}/${scriptRuntime}.js`],
run_at: scriptRuntime
});
}
diff --git a/config/webpack/utils/file-name-hash.js b/config/webpack/utils/file-name-hash.js
new file mode 100644
index 0000000..e3988a9
--- /dev/null
+++ b/config/webpack/utils/file-name-hash.js
@@ -0,0 +1,3 @@
+const crypto = require("crypto");
+
+module.exports.getFileNameHash = fileName => crypto.createHash("md5").update(fileName).digest("hex").substring(16);