aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-13 22:49:42 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-02-13 22:49:42 +0530
commit34ad953c953a395ba3e51c8125034a6bb65b2a79 (patch)
tree253cc30047bb3963f387bd340d50938b3b727053 /config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js
parentaeeabaa0050ecb9e43b1a3fb309f314d92d3ca97 (diff)
downloadbanglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.tar.gz
banglar-bhumi-utils-34ad953c953a395ba3e51c8125034a6bb65b2a79.zip
Fixed not being able to import modules in scripts.
Diffstat (limited to 'config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js')
-rw-r--r--config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js54
1 files changed, 0 insertions, 54 deletions
diff --git a/config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js b/config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js
deleted file mode 100644
index 37c2cf4..0000000
--- a/config/webpack/plugins/sanitize-scripts-import-webpack-plugin.js
+++ /dev/null
@@ -1,54 +0,0 @@
-const { sources } = require("webpack");
-
-const perpectualIndexOf = (string, characterList, start) => {
- if (start > 0) {
- let x = start;
- for (let i = 0; i < characterList.length; i++) {
- x = string.indexOf(characterList[i], x + 1);
- if (x < 0) {
- return -1;
- }
- }
- return x;
- } else {
- return -1;
- }
-};
-
-class SanitizeScriptsImportPlugin {
- apply(compiler) {
- compiler.hooks.compilation.tap("SanitizeScriptsImportPlugin", compilation => {
- compilation.hooks.processAssets.tap(
- {
- name: "SanitizeScriptsImportPlugin",
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE,
- additionalAssets: true
- },
- assets => {
- for (const assetName in assets) {
- if (assetName.endsWith(".js")) {
- const currentAssetContent = compilation.getAsset(assetName).source.source();
- let previouslyEnded = 0;
- let code = "";
- while (true) {
- const start = perpectualIndexOf(currentAssetContent, ["\n/***/", "\n/***/", "\n"], previouslyEnded + 1);
- previouslyEnded = perpectualIndexOf(currentAssetContent, ["\n/***/"], start + 1);
- if (previouslyEnded < 0) {
- break;
- } else {
- code += currentAssetContent.substring(start, previouslyEnded);
- }
- }
- compilation.updateAsset(
- assetName,
- new sources.RawSource(code)
- );
- }
- }
- }
- );
- });
- }
-}
-
-module.exports = SanitizeScriptsImportPlugin;