aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/plugins/create-manifest-webpack-plugin/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'config/webpack/plugins/create-manifest-webpack-plugin/index.js')
-rw-r--r--config/webpack/plugins/create-manifest-webpack-plugin/index.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
index 2187a05..91ddf3e 100644
--- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js
+++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js
@@ -7,8 +7,9 @@ const scripts = webpackRequire("utils/scripts");
const manifest = webpackRequire("plugins/create-manifest-webpack-plugin/manifest-template.json");
class CreateManifestPlugin {
- constructor({ sharedModulesImportedCount, sortedSharedModules }) {
+ constructor({ sharedModulesImportedCount, injectedSharedModulesImportedCount, sortedSharedModules }) {
this.sharedModulesImportedCount = sharedModulesImportedCount;
+ this.injectedSharedModulesImportedCount = injectedSharedModulesImportedCount;
this.sortedSharedModules = sortedSharedModules;
}
@@ -17,8 +18,7 @@ class CreateManifestPlugin {
compilation.hooks.processAssets.tap(
{
name: "CreateManifestPlugin",
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
- additionalAssets: true
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
},
assets => {
manifest.version = require(path.resolve(ROOT_DIR, "package.json")).version;
@@ -33,12 +33,12 @@ class CreateManifestPlugin {
const scriptRuntime = getScriptRuntimeFromType(scriptType);
if (typeof arrangedScripts[scriptPath][scriptRuntime] === "undefined") {
- arrangedScripts[scriptPath][scriptRuntime] = [];
- }
+ arrangedScripts[scriptPath][scriptRuntime] = [];
+ }
- arrangedScripts[scriptPath][scriptRuntime].push(`scripts/${getFileNameHash(scriptType, scriptPath)}.js`);
+ arrangedScripts[scriptPath][scriptRuntime].push(`scripts/${getFileNameHash(scriptType, scriptPath)}.js`);
+ }
}
- }
manifest.content_scripts.push({
matches: [`*://banglarbhumi.gov.in/BanglarBhumi/*`],
@@ -66,7 +66,7 @@ class CreateManifestPlugin {
}
}
- const resources = [];
+ let resources = [];
for (const assetName in assets) {
if (/^assets\/.*\.(jpg|png|gif)$/.test(assetName)) {
@@ -74,6 +74,15 @@ class CreateManifestPlugin {
}
}
+ const injectedSharedModules = this.sortedSharedModules
+ .filter(sharedModule => this.injectedSharedModulesImportedCount[sharedModule] > 0)
+ .map(sharedModule => `shared/${getFileNameHash(sharedModule, "shared")}.js`);
+
+ if (injectedSharedModules.length > 0) {
+ resources = resources.concat(injectedSharedModules);
+ manifest.content_scripts[0].js.unshift(`shared/${getFileNameHash("injected-shared-modules", "shared")}.js`);
+ }
+
if (resources.length > 0) {
manifest.web_accessible_resources = [
{