Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({ resolveConfig, isClient }) => {
let staticPath = resolveConfig.staticPath
const exports = []
if (!checkRuntimeEnv(staticPath)) {
if (!validatePath(staticPath, { allowAbsolutePath: true })) {
throw new Error(
`Incorrect options.staticPath = "${staticPath}"\nValue must be part of the URL or the absolute URL, which is the application's static subdirectory`
)
}
staticPath = encodeURI(staticPath)
exports.push(
`const staticPath = ${JSON.stringify(staticPath)}`,
``,
`export default staticPath`
)
} else {
if (!isClient) {
exports.push(
`import validatePath from 'resolve-runtime/lib/common/utils/validate-path'`
)
export default ({ resolveConfig, isClient }) => {
let rootPath = resolveConfig.rootPath
const exports = []
if (!checkRuntimeEnv(rootPath)) {
if (!validatePath(rootPath, { allowEmptyPath: true })) {
throw new Error(
`Incorrect options.rootPath = "${rootPath}"\nValue must be part of the URL, which is the application's subdirectory`
)
}
rootPath = encodeURI(rootPath)
exports.push(
`const rootPath = ${JSON.stringify(rootPath)}`,
``,
`export default rootPath`
)
} else {
if (!isClient) {
exports.push(
`import validatePath from 'resolve-runtime/lib/common/utils/validate-path'`
)
dependencies: Array.from(resultNodeModules).reduce((acc, val) => {
if (applicationPackageJson.dependencies.hasOwnProperty(val)) {
acc[val] = applicationPackageJson.dependencies[val]
} else if (
resolveRuntimePackageJson.dependencies.hasOwnProperty(val) &&
nodeModules.has(val)
) {
acc[val] = resolveRuntimePackageJson.dependencies[val]
}
return acc
}, {})
}
dependencies: Array.from(resultNodeModules).reduce((acc, val) => {
if (applicationPackageJson.dependencies.hasOwnProperty(val)) {
acc[val] = applicationPackageJson.dependencies[val]
} else if (
resolveRuntimePackageJson.dependencies.hasOwnProperty(val) &&
nodeModules.has(val)
) {
acc[val] = resolveRuntimePackageJson.dependencies[val]
}
return acc
}, {})
}
const prettyPrintUrl = hostname =>
url.format({
protocol,
hostname,
port: chalk.bold(port),
pathname: getRootBasedUrl(rootPath, '/')
})