From e9d2095c1459e3f6c725f7ab209536684e1860c1 Mon Sep 17 00:00:00 2001 From: Mukul Jain Date: Fri, 21 May 2021 01:26:39 +0530 Subject: [PATCH] feat: use API add from env --- package.json | 2 +- src/apps/externalAppShell/index.tsx | 2 +- src/auth/userInfo.tsx | 2 +- src/utils/api/index.ts | 2 +- webpack.common.ts | 18 +----------------- webpack.prod.ts | 15 ++++++--------- 6 files changed, 11 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 7abd38e..a3b46b0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test:watch": "jest --watch", "start": "webpack serve --progress --config webpack.dev.ts", "test:e2e": "cypress open", - "build": "webpack --progress --config webpack.prod.ts --mode=production" + "build": "NODE_ENV=production webpack --progress --config webpack.prod.ts --mode=production" }, "repository": { "type": "git", diff --git a/src/apps/externalAppShell/index.tsx b/src/apps/externalAppShell/index.tsx index 5b9666d..a558a74 100644 --- a/src/apps/externalAppShell/index.tsx +++ b/src/apps/externalAppShell/index.tsx @@ -31,7 +31,7 @@ const ExternalAppShell = ({ }: IProps) => { const { render } = useAnimationEndRender({ instanceId }); const status = useScript( - `http://${process.env.API}/api/manager/assests/${data.appId}/main.js`, + `${process.env.API}/api/manager/assests/${data.appId}/main.js`, true ); console.log(data.options); diff --git a/src/auth/userInfo.tsx b/src/auth/userInfo.tsx index fad0311..97b742f 100644 --- a/src/auth/userInfo.tsx +++ b/src/auth/userInfo.tsx @@ -52,7 +52,7 @@ const Auth = ({ user }: IProps) => { iconProps={{ iconName: "AddFriend" }} allowDisabledFocus onClick={() => { - window.location.href = `http://${process.env.API}/auth/google`; + window.location.href = `${process.env.API}/auth/google`; }} > Continue with Google diff --git a/src/utils/api/index.ts b/src/utils/api/index.ts index 5f7c119..a7c64ee 100644 --- a/src/utils/api/index.ts +++ b/src/utils/api/index.ts @@ -10,7 +10,7 @@ axios.interceptors.request.use((config) => { return { ...config, - baseURL: `http://${process.env.API}/api`, + baseURL: `${process.env.API}/api`, headers: { ...config.headers, Authorization: token, diff --git a/webpack.common.ts b/webpack.common.ts index 933ec97..9723d23 100644 --- a/webpack.common.ts +++ b/webpack.common.ts @@ -58,7 +58,7 @@ const config = { test: /\.(png|jpg|gif)($|\?)/, loader: "url-loader", options: { - limit: 8192, + limit: 4096, }, }, { @@ -74,22 +74,6 @@ const config = { }, ], }, - externals: { - // react: { - // root: "React", - // commonjs2: "react", - // commonjs: "react", - // amd: "react", - // umd: "react", - // }, - // "react-dom": { - // root: "ReactDOM", - // commonjs2: "react-dom", - // commonjs: "react-dom", - // amd: "react-dom", - // umd: "react-dom", - // }, - }, }; module.exports = config; diff --git a/webpack.prod.ts b/webpack.prod.ts index 80b6f38..09fa507 100644 --- a/webpack.prod.ts +++ b/webpack.prod.ts @@ -16,16 +16,9 @@ const config = { path: path.resolve("./dist"), }, optimization: { - usedExports: true, splitChunks: { - cacheGroups: { - vendor: { - // just need to exclude these they will created by webpack as other chunk - test: /.?[\\/]node_modules[\\/](?!(react-pdf|pdfjs-dist|react-table|d3)).*?/, - name: "vendors", - chunks: "all", - }, - }, + // include all types of chunks + chunks: "all", }, }, @@ -51,6 +44,10 @@ const config = { openAnalyzer: true, }), ], + externals: { + react: "React", + "react-dom": "ReactDOM", + }, }; module.exports = merge(common, config);