UNPKG

infrastructure-components

Version:

Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.

33 lines (21 loc) 1.04 kB
/** * the resolved assets path is the path ot the assets folder in the running environment */ export const resolveAssetsPath = (buildPath: string, serverName: string, assetsPath: string) => { const path = require('path'); const resolvedPath = path.resolve(buildPath, serverName, assetsPath); return !resolvedPath.endsWith("/") ? resolvedPath+"/" : resolvedPath; }; export const getStaticBucketName = (stackName: string, assetsPath: string | undefined, stage: string) => { return `infrcomp-${stackName}-${assetsPath !== undefined ? assetsPath+"-" : ""}${stage}`; } export const getBasename = () => { // first check whether we are a client if (typeof window != 'undefined' && window.__BASENAME__) { return window.__BASENAME__; // we do not delete the basename here, because we may need it at different places //delete window.__BASENAME__; } return process.env.STAGE_PATH !== undefined && process.env.STAGE_PATH !== "undefined" ? "/"+process.env.STAGE_PATH : "/"; };