Skip to content

Commit ad5d6c1

Browse files
author
徐远翔
committed
feat: 支持umi define配置
1 parent b809dbe commit ad5d6c1

File tree

1 file changed

+10
-0
lines changed
  • packages/umi-preset-react-native/src/plugins/generateFiles/react-native

1 file changed

+10
-0
lines changed

packages/umi-preset-react-native/src/plugins/generateFiles/react-native/polyfill.ts

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ export default (api: IApi) => {
2121
return memo;
2222
});
2323

24+
api.addEntryCodeAhead(() => {
25+
if (api.config.define && typeof api.config.define === 'object') {
26+
const keys = Object.keys(api.config.define);
27+
return keys
28+
.map((key) => `global['${key}'] = ${JSON.stringify(api.config.define && api.config.define[key])};`)
29+
.join('\n');
30+
}
31+
return '';
32+
});
33+
2434
api.addEntryCode(
2535
() => `// @ts-ignore
2636
let accept: unknown;

0 commit comments

Comments
 (0)