diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-14 09:46:34 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-02-14 09:46:34 +0530 |
| commit | a30b28d40e5bacdbbbcad3c9de8f1fe3e083119c (patch) | |
| tree | c2f367c5ea4179911a0c2d279a2e980a96414d26 /config/webpack/plugins/create-manifest-webpack-plugin/index.js | |
| parent | 34ad953c953a395ba3e51c8125034a6bb65b2a79 (diff) | |
| download | banglar-bhumi-utils-a30b28d40e5bacdbbbcad3c9de8f1fe3e083119c.tar.gz banglar-bhumi-utils-a30b28d40e5bacdbbbcad3c9de8f1fe3e083119c.zip | |
Added ability to load static assets from extension's assets.
Diffstat (limited to 'config/webpack/plugins/create-manifest-webpack-plugin/index.js')
| -rw-r--r-- | config/webpack/plugins/create-manifest-webpack-plugin/index.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index 3a16770..a1a21a8 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -14,7 +14,7 @@ class CreateManifestPlugin { stage: compiler.webpack.Compilation.PROCESS_ASSETS_ADDITIONAL, additionalAssets: true }, - () => { + assets => { const scripts = formatScripts(require(path.resolve(SOURCE_DIR, "scripts.json"))); const manifest = webpackRequire("plugins/create-manifest-webpack-plugin/manifest-template.json"); manifest.version = require(path.resolve(ROOT_DIR, "package.json")).version; @@ -30,6 +30,23 @@ class CreateManifestPlugin { } } + const resources = []; + + for (const assetName in assets) { + if (/^assets\/.*\.(jpg|png|gif)$/.test(assetName)) { + resources.push(assetName); + } + } + + if (resources.length > 0) { + manifest.web_accessible_resources = [ + { + resources, + matches: [ "<all_urls>" ] + } + ]; + } + compilation.emitAsset( "manifest.json", new sources.RawSource(JSON.stringify(manifest)) |
