我正在使用 Preact 3.0。我style在模板 index.html 檔案中有幾個標簽。目的是在建造程序中保持它。例如,
<style id="keep-this-tag">
some-styles-that-should-not-be-put-in-style.css-file
</style>
uj5u.com熱心網友回復:
您需要標簽本身留下來嗎?
如果是這樣,只需使用以下配置,或添加到您現有的:
// preact.config.js
export default (config, env, helpers) => {
const critters = helpers.getPluginsByName(config, 'Critters')[0];
if (critters) {
critters.plugin.options.mergeStylesheets = false;
}
}
Critters 用于關鍵的 CSS 行內,默認情況下,它將您的樣式標簽合并在一起。雖然很容易禁用,但希望這會有所幫助。
編輯:禁用預渲染后,Critters 將洗掉所有 CSS,因為它們都被認為是“未使用的”。要禁用小動物,您可以使用--no-inline-css標志,即preact build --no-inline-css。
你確實失去了行內,但沒有辦法繞過它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/357621.html
