Repository URL to install this package:
|
Version:
3.8.1 ▾
|
/**
* @todo @file move this out
*/
// import fwf from 'funwithflags'
import { resolveToRoot } from '../resolveToRoot'
// @todo @@perf remove
function ENV_FLAGS() {
const NODE_ENV = process.env.NODE_ENV
const DEV = process.env.DEV_ENV === true || NODE_ENV === 'development'
const PROD = process.env.NODE_ENV === 'production' || process.env.PRODUCTION === true
const WEBPACK = process.env.WEBPACK_ENV === true
const STORYBOOK = process.env.STORYBOOK_ENV === true
const SERVER = process.env.SERVER_ENV === true
const TEST = NODE_ENV === 'test'
const DEPLOYMENT = Boolean(process.env.DEPLOYMENT)
return {
DEV,
PROD,
WEBPACK,
STORYBOOK,
SERVER,
TEST,
}
}
const FLAGS = ENV_FLAGS()
// @todo to get `isAnalyze`
// const argv = fwf.argv()
function configOptions(buildOptions) {
const { optimize, target } = buildOptions
const isAnalyze = process.env.BUILD_ANALYZE
// @note this checks whether --optimize || NODE_ENV = production
const isProd = Boolean(optimize || process.env.NODE_ENV === 'production')
const isDev = !isProd
const isClient = target === 'client'
const isServer = target === 'server'
const isNode = !isClient
const isProdClient = Boolean(isProd && isClient)
const isProdServer = Boolean(isProd && isServer)
const isDevClient = Boolean(isDev && isClient)
const isDevServer = Boolean(isDev && isServer)
// -------- should not need docs -----------
// Preconfigure some ifElse helper instnaces. See the util docs for more
// information on how this util works.
// const ifDev = ifElse(isDev)
// const ifProd = ifElse(isProd)
// const ifNode = ifElse(isNode)
// const ifClient = ifElse(isClient)
// const ifDevClient = ifElse(isDev && isClient)
// const ifProdClient = ifElse(isProd && isClient)
// const ifAny = ifElse(true)
return {
...buildOptions,
isAnalyze,
isDevClient,
isProdServer,
isProdClient,
isDevServer,
isProd,
isDev,
isClient,
isServer,
// ...FLAGS,
}
}
export { configOptions }
export default configOptions