aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-04-11 20:37:34 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-04-11 20:37:34 +0530
commitb604cb63c8b4a28e4c31708460463ea492cf696e (patch)
tree9e91e8f032e61e19ad0662fb0d7ea1da987cc144 /config/webpack
parentcf38f96900bb11a5c795f9547319402d6a18b027 (diff)
downloadbanglar-bhumi-utils-b604cb63c8b4a28e4c31708460463ea492cf696e.tar.gz
banglar-bhumi-utils-b604cb63c8b4a28e4c31708460463ea492cf696e.zip
Using a seperate HTML file for the generating the PDF.
Putting the footer at the bottom of each page.
Diffstat (limited to 'config/webpack')
-rw-r--r--config/webpack/loader/to-string-loader.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/config/webpack/loader/to-string-loader.js b/config/webpack/loader/to-string-loader.js
new file mode 100644
index 0000000..cf26b28
--- /dev/null
+++ b/config/webpack/loader/to-string-loader.js
@@ -0,0 +1,41 @@
+module.exports = function(source) {
+ source = source
+ .replaceAll("\\", "\\\\")
+ .replaceAll("`","\\`")
+ .replaceAll("${", "\\${");
+
+ const replacements = {};
+ let i = 0;
+ while (true) {
+ i = source.indexOf("$", i) + 1;
+
+ if (i <= 0) {
+ break;
+ }
+
+ const end = source.indexOf("$", i);
+
+ if (end < 0) {
+ break;
+ }
+
+ const replacementVariable = source.substring(i, end);
+ replacements[replacementVariable] = 1;
+ source = source.substring(0, i - 1) + `\${${replacementVariable}}` + source.substring(end + 1);
+ i = end + 1;
+ }
+
+ source = `\`${source}\``;
+
+ const replacementList = [];
+
+ for (const replacement in replacements) {
+ replacementList.push(replacement);
+ }
+
+ const replacementArguments = replacementList.length > 0
+ ? `{ ${replacementList.join(", ")} }`
+ : "";
+
+ return `export default (${replacementArguments}) => ${source};`;
+};