Skip to content

Commit

Permalink
fixed service worker for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
amitsingh-007 committed Dec 12, 2020
1 parent c9b6525 commit 6bfb5cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import DownloadPage from "GlobalComponents/DownloadPage";
import "preact/devtools";
import React, { StrictMode } from "react";
import ReactDOM from "react-dom";
import { isProd } from "./utils/index";

const theme = createMuiTheme({
palette: {
Expand All @@ -23,7 +24,7 @@ ReactDOM.render(
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register("/sw.js")
.register(`/${isProd() ? "bypass-links/" : ""}sw.js`)
.then((res) => {
console.log("service worker registered", res);
})
Expand Down
9 changes: 8 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
exports.getExtensionFile = (version) => `bypass-links-${version}.zip`;
const getExtensionFile = (version) => `bypass-links-${version}.zip`;

const isProd = () => process.env.NODE_ENV === "production";

module.exports = {
getExtensionFile,
isProd,
};
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const WebpackBundleAnalyzerPlugin = require("webpack-bundle-analyzer")
const FileManagerPlugin = require("filemanager-webpack-plugin");
const { InjectManifest } = require("workbox-webpack-plugin");
const webpack = require("webpack");
const { getExtensionFile } = require("./src/utils");
const { getExtensionFile, isProd } = require("./src/utils");
const { releaseDate, extVersion } = require("./release-config");

const ENV = process.env.NODE_ENV || "production";
const isProduction = ENV === "production";
const ENV = process.env.NODE_ENV;
const isProduction = isProd();
const enableBundleAnalyzer = process.env.ENABLE_BUNDLE_ANLYZER === "true";
const isDevServer = process.env.DEV_SERVER === "true";

Expand Down

0 comments on commit 6bfb5cc

Please sign in to comment.