diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2025-06-13 18:30:50 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2025-06-13 18:30:50 +0530 |
| commit | bce4cff7f7144bc91d780e2dd2f8e1114109f407 (patch) | |
| tree | bf528a65b9e4f3e99d780e71f7e7cff368dbc068 /config | |
| parent | 976ae51dabe77686e405a2b99127485209c7c9cd (diff) | |
| download | banglar-bhumi-utils-bce4cff7f7144bc91d780e2dd2f8e1114109f407.tar.gz banglar-bhumi-utils-bce4cff7f7144bc91d780e2dd2f8e1114109f407.zip | |
Added background scripts.
Diffstat (limited to 'config')
| -rw-r--r-- | config/webpack.config.js | 44 | ||||
| -rw-r--r-- | config/webpack/plugins/create-manifest-webpack-plugin/index.js | 2 |
2 files changed, 33 insertions, 13 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 70b87ca..1d3b4c0 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -35,12 +35,21 @@ for (const sharedModule of sharedModules) { injectedSharedModulesImportedCount[sharedModule] = 0; } +const backgroundScriptEntries = {}; const uninjectedScriptEntries = {}; const injectedAfterScriptEntries = {}; const injectedBeforeScriptEntries = {}; const sharedModuleEntries = {}; const sharedModuleExternals = {}; +const backgroundScriptImports = fs.readdirSync(path.resolve(SOURCE_DIR, "background")) + .map(scriptName => `import "${path.resolve(SOURCE_DIR, "background", scriptName)}";`) + .join("\n"); +backgroundScriptEntries["background script"] = { + import: inlineJavascript(backgroundScriptImports), + filename: "background.js" +}; + for (const scriptPath in scripts) { for (const scriptType in scripts[scriptPath]) { const currentScripts = scripts[scriptPath][scriptType]; @@ -84,8 +93,8 @@ const commonOptions = { resolve: { extensions: [".ts", ".js", ".html"], alias: { - "@": global.SOURCE_DIR - } + "@": global.SOURCE_DIR, + }, }, module: { rules: [ @@ -93,27 +102,27 @@ const commonOptions = { test: /\.ts$/, loader: "ts-loader", options: { - configFile: "config/tsconfig.json" + configFile: "config/tsconfig.json", } }, { test: /\.html$/, - loader: path.resolve(CONFIG_DIR, "webpack/loader/to-string-loader.js") - } - ] + loader: path.resolve(CONFIG_DIR, "webpack/loader/to-string-loader.js"), + }, + ], }, optimization: { minimize: process.env.NODE_ENV === "production", - runtimeChunk: false + runtimeChunk: false, }, output: { - iife: true + iife: true, }, plugins: [ new webpack.optimize.LimitChunkCountPlugin({ - maxChunks: 1 - }) - ] + maxChunks: 1, + }), + ], }; const sharedModuleOptions = { @@ -125,14 +134,22 @@ const sharedModuleOptions = { test: /banglar-bhumi-utils\/src\/.*.(^.?|\.[^d]|[^.]d|[^.][^d])\.(t|j)s$/, loader: path.resolve(CONFIG_DIR, "webpack/loader/count-imports-loader.js"), options: { - sharedModulesImportedCount + sharedModulesImportedCount, }, - enforce: "post" + enforce: "post", } ] } }; +const backgroundScriptConfiguration = merge( + commonOptions, + sharedModuleOptions, + { + entry: backgroundScriptEntries, + }, +); + const uninjectedScriptConfiguration = merge( commonOptions, sharedModuleOptions, @@ -206,6 +223,7 @@ const sharedModulesConfiguration = merge( ); module.exports = [ + backgroundScriptConfiguration, uninjectedScriptConfiguration, injectedScriptConfiguration, sharedModulesConfiguration diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index 8dc0ae4..330c22f 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -97,6 +97,8 @@ class CreateManifestPlugin { ]; } + manifest.background = { service_worker: "background.js" }; + compilation.emitAsset( "manifest.json", new sources.RawSource( |
