You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
When I run the metro server in development mode and start it separately, I can easily pass the environment variables like
ENVFILE=.env.dev react-native start
I can then easily read this environment variable in meto.config.js and perform certain actions. But when I try to build the app from production the react-native server is started on its own by the run-ios or run-android command. I am passing the environment variable to these scripts as
ENVFILE=.env.prod react-native run-ios
I can easily access this value in the code, but when I try to access the same in metro.config.js it returns as undefined. I want to know if there is a way to pass the environment variables to metro server when creating the production application.
What is the current behavior?
Current behaviour seems to be that the environment variables are not passed to metro server, if it is not started separately.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
None
What is the expected behavior?
Expected behaviour is that the environment variables passed to run-ios and run-android scripts should be forwarded to react-native start command as well.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
// List of folders and files to be excluded
// let listToBeExcluded = [/.test.js$/];
// if (!(process.env.NODE_ENV === "development")) {
// listToBeExcluded = [
// ...listToBeExcluded,
// /src/modules/NonProdOptions/.*/,
// ];
// }
Do you want to request a feature or report a bug?
When I run the metro server in development mode and start it separately, I can easily pass the environment variables like
ENVFILE=.env.dev react-native start
I can then easily read this environment variable in meto.config.js and perform certain actions. But when I try to build the app from production the react-native server is started on its own by the run-ios or run-android command. I am passing the environment variable to these scripts as
ENVFILE=.env.prod react-native run-ios
I can easily access this value in the code, but when I try to access the same in metro.config.js it returns as undefined. I want to know if there is a way to pass the environment variables to metro server when creating the production application.
What is the current behavior?
Current behaviour seems to be that the environment variables are not passed to metro server, if it is not started separately.
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can
yarn install
andyarn test
.None
What is the expected behavior?
Expected behaviour is that the environment variables passed to run-ios and run-android scripts should be forwarded to react-native start command as well.
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
`
const { getDefaultConfig } = require("metro-config");
// const exclusionList = require("metro-config/src/defaults/exclusionList");
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts },
} = await getDefaultConfig();
// List of folders and files to be excluded
// let listToBeExcluded = [/.test.js$/];
// if (!(process.env.NODE_ENV === "development")) {
// listToBeExcluded = [
// ...listToBeExcluded,
// /src/modules/NonProdOptions/.*/,
// ];
// }
return {
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer"),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== "svg"),
sourceExts: [...sourceExts, "svg"],
// blockList: exclusionList(listToBeExcluded),
},
maxWorkers: 2,
};
})();`
yarn: 1.22.19
node: v19.8.1
OS: macOS Vetura(13.2.1)
The text was updated successfully, but these errors were encountered: