Akshey Jawa
Akshey Jawa

Reputation: 447

webpack configuration in preact-cli

I created an app using preact-cli. I want to change some configuration of webpack. I created preact.config.js and passed it to 'preact build' through '--config'. I added this piece of code in preact.config.js to switch off 'hints'.

export default function (config, env, helpers) {

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

}

It is throwing an error: Cannot set property 'hints' of undefined. I expect performance.hints= "warning" to be passed on to webpack as a configuration parameter.

Upvotes: 0

Views: 5155

Answers (1)

Dan
Dan

Reputation: 36

you have the option of modifying the original webpack config directly (example)

it's passed in via the config parameter

this lets us do something like this:

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

multiple webpack configs are passed through this function

so we check for the performance property first as it is only present in certain circumstances (docs)

Upvotes: 2

Related Questions