你的提案是否与问题相关?
目前,没有对预加载或预取资源(如字体和CSS)的原生支持。解决方法是编写一个Node脚本来修改生成的index.html
。然而,用户不应该这样做,这种技巧相当脏。
(在这里写下你的答案。)
描述你希望的解决方案
(在这里描述你提出的解决方案。)
对预加载或预取资源的原生支持,这将被翻译成类似以下内容:
字体:
<link rel="preload" href="/static/media/font.woff2" as="font" type="font/woff2" crossorigin />
CSS:
<link rel="preload" href="styles.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="styles.css"></noscript>
2条答案
按热度按时间icnyk63a1#
关于这个问题,在#3319中有讨论。据我所知,我们正在等待
html-webpack-plugin
支持这个功能,并且在jantimon/html-webpack-plugin#934中的每次对话中都会提到。我不知道这是否会很快实现。在此期间,你可能可以查看https://github.com/jantimon/resource-hints-webpack-plugin和https://github.com/GoogleChromeLabs/preload-webpack-plugin,但需要弹出或扩展webpack配置。
ldfqzlk82#
有任何消息吗?看起来jantimon/html-webpack-plugin#934现在关闭了!