為什么80%的碼農都做不了架構師?>>> ??
靜態資源在非根目錄或 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