美文网首页
create-react-app build后资源无法找到

create-react-app build后资源无法找到

作者: EasonChan94 | 来源:发表于2019-01-09 14:20 被阅读0次

    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": "."
    

    相关文章

      网友评论

          本文标题:create-react-app build后资源无法找到

          本文链接:https://www.haomeiwen.com/subject/drxgrqtx.html