UmiJS CDN 部署之 publicPath

原创
2019/05/30 09:37
阅读数 2.7W

静态资源在非根目录或 cdn 这时,就需要配置 publicPath。至于 publicPath 是啥?具体看 webpack 文档,把他指向静态资源(js、css、图片、字体等)所在的路径。

export default { 
  publicPath: "http://yourcdn/path/to/static/" 
}

使用 runtime 的 publicPath

对于需要在 html 里管理 publicPath 的场景,比如在 html 里判断环境做不同的输出,可通过配置 runtimePublicPath 为解决。

export default { 
  runtimePublicPath: true, 
}; 

然后在 html 里输出:

<script> window.publicPath = <%= YOUR PUBLIC_PATH %> </script>

https://umijs.org/zh/guide/deploy.html

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部