const hq = require("alias-hq"); const aliases = hq.get("webpack"); exports.cocoPath = function (aliasedPath, relative = false) { const pathParts = aliasedPath.split("/"); const alias = pathParts.shift(); const restPath = pathParts.join("/"); if (aliases[alias]) { const rootPath = aliases[alias].replace(/\/$/, ""); const path = restPath.length ? `${rootPath}/${restPath}` : rootPath; return relative ? path.replace(process.cwd(), "").replace(/^\//, "") : path; } else { throw new Error(`'${alias}' is not a valid path alias.`); } };