infrastructure-components
Version:
Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.
86 lines • 3.57 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const environment_component_1 = require("./environment-component");
const deepmerge = __importStar(require("deepmerge"));
const parser_1 = require("../libs/parser");
/**
* A Plugin to detect WebApp-Components
* @param props
*/
exports.EnvironmentPlugin = (props) => {
const path = require('path');
const result = {
// identify Isomorphic-App-Components
applies: (component) => {
return environment_component_1.isEnvironment(component);
},
// convert the component into configuration parts
// while the component is of Type `any`, its props must be of type `IWebApp`
process: (component, childConfigs, infrastructureMode) => {
// when we did not provide a stage, we evaluate all stages, but only with regard to the b
if (props.stage === undefined) {
console.log(`No stage specified, load environment ${component.name} in build mode`);
return {
slsConfigs: [],
webpackConfigs: [],
postBuilds: [],
environments: [component]
};
}
else if (props.stage !== component.name) {
// we ignore any environment that does not match the specified one!
console.log(`environment ${component.name} does not apply to specified ${props.stage}`);
return {
slsConfigs: [],
webpackConfigs: [],
postBuilds: []
};
}
console.log("apply environment: ", component);
return {
slsConfigs: deepmerge.all([
{
// set the stage-name
provider: {
STAGE: component.name
}
},
component.offlinePort !== undefined && props.parserMode === parser_1.PARSER_MODES.MODE_START ? {
provider: {
PORT: component.offlinePort
}
} : {},
// the stage path is valid only
component.stagePath !== undefined && props.parserMode === parser_1.PARSER_MODES.MODE_DEPLOY ? {
provider: {
STAGE_PATH: component.name
}
} : {},
component.domain !== undefined ? {
plugins: ["serverless-domain-manager"],
custom: {
customDomain: {
domainName: component.domain,
basePath: '',
stage: component.name,
createRoute53Record: true
}
}
} : {}
]),
webpackConfigs: [],
postBuilds: [],
environments: [component]
};
}
};
return result;
};
//# sourceMappingURL=environment-plugin.js.map