2017-10-11 47 views
0

我使用preact-cli創建了一個應用程序。我想改變一些webpack的配置。我創建了preact.config.js,並通過'--config'將它傳遞給'preact build'。我在preact.config.js中添加了這段代碼來關閉'提示'。preact-cli中的webpack配置

export default function (config, env, helpers) { 

    helpers.webpack.performance.hints= "warning"; 

} 

它引發了一個錯誤:Cannot set property 'hints' of undefined。 我希望performance.hints= "warning"作爲配置參數傳遞給webpack。

回答

1

你有直接(example

它通過config參數

通過了修改原有的WebPack配置的選項,這可以讓我們做這樣的事情:

if (config.performance) { 
    config.performance.hints = false; 
} 

多的WebPack配置通過此功能

所以我們檢查performance財產第一,因爲它只存在於某些情況下(docs