CRA定义的PUBLIC_URL里面的源码:
const envPublicUrl = process.env.PUBLIC_URL;
const getPublicUrl = appPackageJson =>
envPublicUrl || require(appPackageJson).homepage;
function getServedPath(appPackageJson) {
const publicUrl = getPublicUrl(appPackageJson);
const servedUrl =
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
return ensureSlash(servedUrl, true);
}
默认会被替换为空 然后变为 / 目录
如果是生产环境 在package.json里面配置
"homepage": "."