Skip to content

Commit

Permalink
Merge pull request #162 from amitsingh-007/f-fix-service-worker-size-…
Browse files Browse the repository at this point in the history
…and-behaviour

fix serviceworker size and behaviour
  • Loading branch information
amitsingh-007 authored Dec 14, 2020
2 parents 67eafa2 + 3d868ba commit dc39cdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
13 changes: 0 additions & 13 deletions src/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ import { NetworkFirst } from "workbox-strategies";
self.skipWaiting();
precacheAndRoute(self.__WB_MANIFEST);

registerRoute(
/.*/,
new NetworkFirst({
cacheName: "bypass-links-cache",
plugins: [
new ExpirationPlugin({
maxEntries: 20,
maxAgeSeconds: 7 * 24 * 60 * 60, // 1 week
}),
],
})
);

registerRoute(
/.*(bypass-links-.*).*\.zip$/,
new NetworkFirst({
Expand Down
18 changes: 12 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const isProduction = ENV === "production";
const enableBundleAnalyzer = process.env.ENABLE_BUNDLE_ANLYZER === "true";
const isDevServer = process.env.DEV_SERVER === "true";

const PATHS = {
BUILD: path.resolve(__dirname, "build"),
EXTENSION: path.resolve(__dirname, "extension"),
SRC: path.resolve(__dirname, "src"),
};

const commonConfig = {
mode: ENV,
resolve: {
Expand All @@ -35,7 +41,7 @@ const commonConfig = {
react: "preact/compat",
"react-dom": "preact/compat",
},
modules: [path.resolve(__dirname, "..", "src"), "node_modules"],
modules: [PATHS.SRC, "node_modules"],
},
stats: isProduction ? "normal" : "errors-warnings",
devtool: isProduction ? undefined : "eval-cheap-module-source-map",
Expand All @@ -62,7 +68,7 @@ const fileManagerPluginCommonConfig = {
delete: [`./extension/{${enableBundleAnalyzer ? "" : "stats.json,"}*.txt}`],
archive: [
{
source: path.resolve(__dirname, "extension"),
source: PATHS.EXTENSION,
destination: `./build/${getExtensionFile(extVersion)}`,
},
],
Expand Down Expand Up @@ -121,7 +127,7 @@ const getPopupConfigPlugins = () => {
copy: [
{
source: "./assets/*",
destination: path.resolve(__dirname, "extension"),
destination: PATHS.EXTENSION,
},
],
},
Expand Down Expand Up @@ -164,7 +170,7 @@ const downloadPageConfig = {
...commonConfig,
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "build"),
path: PATHS.BUILD,
filename: "js/[name].[chunkhash:9].js",
chunkFilename: "js/[name].[chunkhash:9].js",
pathinfo: false,
Expand Down Expand Up @@ -223,7 +229,7 @@ const backgroundConfig = {
...commonConfig,
entry: "./src/scripts/background.js",
output: {
path: path.resolve(__dirname, "extension"),
path: PATHS.EXTENSION,
filename: "background.js",
},
target: "browserslist",
Expand All @@ -234,7 +240,7 @@ const popupConfig = {
...commonConfig,
entry: "./src/popupIndex.js",
output: {
path: path.resolve(__dirname, "extension"),
path: PATHS.EXTENSION,
filename: "popup.js",
},
target: "browserslist",
Expand Down

0 comments on commit dc39cdc

Please sign in to comment.