Repository URL to install this package:
|
Version:
3.5.1 ▾
|
/* eslint max-statements: "OFF" */
// const { getConfigForEnv } = require('../oneConfig/getConfigForEnv')
/**
* @todo @james @fixme @important public path SHOULD be absolute as a non fully qualified domain name
* @example /client/ > http://0.0.0:444/client/
*
* @param {any} bundlingOptions
* @returns
*/
function getURLs(bundlingOptions) {
// log.data(bundlingOptions).echo()
const { isDev, isProd, isClient } = bundlingOptions
/**
* @deprecated this commented out way
* will be tree shaken when static - we want this as dynamic
*
* @constant
* @static
* @example
* const { bundleConfig } = bundlingOptions
* const { host, port, clientDevServerPort } = bundlingOptions
*
* -------------
* @event refactored |>>
*/
// /server/??? not a web path....
const webPath =
isClient || isProd ? process.env.WEB_PATH || '/client/' : '/server/'
const named = isClient ? 'client' : 'server'
// @note - made it always localhost:3000 which may be a problem
const DEV_ABSOLUTE_URL =
(process.env.SERVER_URL || 'http://localhost:3000') + webPath
const DEV_HMR_URL = `webpack-hot-middleware/client?path=/__webpack_hmr?name=${named}`
// dev
const outputPublicPath = DEV_ABSOLUTE_URL
let clientServerPublicPath = outputPublicPath
if (isProd) {
clientServerPublicPath = webPath
}
bundlingOptions.DEV_HMR_URL = DEV_HMR_URL
bundlingOptions.outputPublicPath = outputPublicPath
bundlingOptions.clientServerPublicPath = clientServerPublicPath
bundlingOptions.webPath = webPath
return {
DEV_HMR_URL,
outputPublicPath,
clientServerPublicPath,
webPath,
}
}
export { getURLs }
export default getURLs