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);
}
默認會被替換為空 然后變?yōu)?/ 目錄
如果是生產(chǎn)環(huán)境 在package.json里面配置
"homepage": "."