@craco/craco
Version:
Create React App Configuration Override, an easy and comprehensible configuration layer for create-react-app.
36 lines (28 loc) • 795 B
JavaScript
const { isString } = require("../../utils");
function setEnvironmentVariable(envProperty, value) {
if (!isString(value)) {
process.env[envProperty] = value.toString();
} else {
process.env[envProperty] = value;
}
}
function setEnvironmentVariables(cracoConfig) {
if (cracoConfig.devServer) {
const { open, https, host, port } = cracoConfig.devServer;
if (open === false) {
setEnvironmentVariable("BROWSER", "none");
}
if (https) {
setEnvironmentVariable("HTTPS", "true");
}
if (host) {
setEnvironmentVariable("HOST", host);
}
if (port) {
setEnvironmentVariable("PORT", port);
}
}
}
module.exports = {
setEnvironmentVariables
};