diff options
Diffstat (limited to 'config/webpack/plugins')
| -rw-r--r-- | config/webpack/plugins/create-manifest-webpack-plugin/index.js | 4 | ||||
| -rw-r--r-- | config/webpack/plugins/inject-script-webpack-plugin.js | 24 |
2 files changed, 13 insertions, 15 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index 4ab363f..785d604 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -29,7 +29,7 @@ class CreateManifestPlugin { manifest.content_scripts.push({ matches, - js: [`scripts/${getFileNameHash(scriptPath)}-${scriptType}.js`], + js: [`scripts/${getFileNameHash(scriptType, scriptPath)}.js`], run_at: getScriptRuntimeFromType(scriptType) }); } @@ -44,7 +44,7 @@ class CreateManifestPlugin { } for (const sharedModule of sharedModules) { - resources.push(`shared/${getFileNameHash(sharedModule)}.js`); + resources.push(`shared/${getFileNameHash(sharedModule, "shared")}.js`); } if (resources.length > 0) { diff --git a/config/webpack/plugins/inject-script-webpack-plugin.js b/config/webpack/plugins/inject-script-webpack-plugin.js index 862b3f0..c597e9a 100644 --- a/config/webpack/plugins/inject-script-webpack-plugin.js +++ b/config/webpack/plugins/inject-script-webpack-plugin.js @@ -3,6 +3,10 @@ const { sources } = require("webpack"); const { getInjectionCode } = webpackRequire("utils/get-injection-code"); class InjectScriptPlugin { + constructor(insertedBefore = false) { + this.insertedBefore = insertedBefore; + } + apply(compiler) { compiler.hooks.compilation.tap("InjectScriptPlugin", compilation => { compilation.hooks.processAssets.tapPromise( @@ -13,21 +17,15 @@ class InjectScriptPlugin { }, async assets => { for (const assetName in assets) { - let injected = false; - let injected_before = false; - - if (assetName.endsWith("injected.js")) - injected = true; - - else if (assetName.endsWith("injected-before.js")) { - injected = true; - injected_before = true; - } - - if (injected) { + if (/\.js$/.test(assetName)) { compilation.updateAsset( assetName, - new sources.RawSource(getInjectionCode(compilation.getAsset(assetName).source.source(), injected_before)) + new sources.RawSource( + getInjectionCode( + compilation.getAsset(assetName).source.source(), + this.insertedBefore + ) + ) ); } } |
