aboutsummaryrefslogtreecommitdiffstats
path: root/config
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
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')
-rw-r--r--config/tsconfig.json3
-rw-r--r--config/webpack.config.js6
-rw-r--r--config/webpack/loader/to-string-loader.js41
3 files changed, 49 insertions, 1 deletions
diff --git a/config/tsconfig.json b/config/tsconfig.json
index 120bfcb..ec61595 100644
--- a/config/tsconfig.json
+++ b/config/tsconfig.json
@@ -1,4 +1,7 @@
{
+ "files": [
+ "../src/html.d.ts"
+ ],
"compilerOptions": {
"outDir": "dist",
"sourceMap": true,
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 31bbb8d..2ae6544 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -84,7 +84,7 @@ const commonOptions = {
mode: "production",
target: "web",
resolve: {
- extensions: [".ts", ".js"],
+ extensions: [".ts", ".js", ".html"],
alias: {
"@": global.SOURCE_DIR
}
@@ -97,6 +97,10 @@ const commonOptions = {
options: {
configFile: "config/tsconfig.json"
}
+ },
+ {
+ test: /\.html$/,
+ loader: path.resolve(CONFIG_DIR, "webpack/loader/to-string-loader.js")
}
]
},
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};`;
+};