Skip to content

Commit a78eaf6

Browse files
author
HienTM
committed
fix: set __webpack_public_path__ directly
1 parent 693f66f commit a78eaf6

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

dist/index.es.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,8 @@ const MicroFrontendRoutesComponent = ({ fallback, routeProps, }) => (React.creat
138138
const MicroFrontendRoutes = memo(MicroFrontendRoutesComponent);
139139
MicroFrontendRoutes.displayName = 'MicroFrontendRoutes';
140140

141-
const PUBLIC_PATH_KEY = '__webpack_public_path__';
142141
const setPublicPath = () => {
143-
const win = window;
144-
win[PUBLIC_PATH_KEY] = process.env.REACT_APP_PUBLIC_PATH;
142+
__webpack_public_path__ = process.env.REACT_APP_PUBLIC_PATH;
145143
};
146144

147145
const bootstrapContainer = () => {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"lint:fix": "yarn lint --fix",
2323
"prebuild": "del dist",
2424
"release": "release-it",
25-
"size": "yarn build && size-limit",
25+
"size": "size-limit",
2626
"type-check": "tsc --noEmit"
2727
},
2828
"dependencies": {

src/setPublicPath.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
const PUBLIC_PATH_KEY = '__webpack_public_path__';
1+
/* eslint-disable no-underscore-dangle */
2+
/* eslint-disable @typescript-eslint/camelcase */
3+
declare let __webpack_public_path__: string | undefined;
24

35
const setPublicPath = () => {
4-
const win = (window as unknown) as PublicPathWindow;
5-
win[PUBLIC_PATH_KEY] = process.env.REACT_APP_PUBLIC_PATH;
6+
__webpack_public_path__ = process.env.REACT_APP_PUBLIC_PATH;
67
};
78

89
export default setPublicPath;
9-
10-
interface PublicPathWindow {
11-
[PUBLIC_PATH_KEY]: string | undefined;
12-
}

0 commit comments

Comments
 (0)