next-compose-plugins
next-compose-plugins copied to clipboard
[Bug] Breaks on apply a plugin only during development server phase
Hi there,
First of all, thanks for this amazing plugin which I really find useful. I'm just running an issue where I'd like to run some stuff on just development server phase. To facilitate I'll paste here some of the code:
module.exports = withPlugins(
[
[() => console.log('It breaks'), [PHASE_DEVELOPMENT_SERVER]],
],
nextConfig,
)
To avoid the type error the solution would be some safe key checking on updatedConfig
https://github.com/cyrilwanner/next-compose-plugins/blob/master/src/compose.js#L102
Sorry I lack of the context to give more useful information on why it may happen. For now what I've made to solve it is by creating a simple plugin.
A generic example:
const myPlugin = (nextConfig = {}, nextComposePlugins) => {
if (
PHASE_DEVELOPMENT_SERVER &&
[PHASE_DEVELOPMENT_SERVER].includes(
nextComposePlugins && nextComposePlugins.phase,
)
)
// Do some stuff just on development
return nextConfig
}
Then:
module.exports = withPlugins(
[
myPlugin
],
nextConfig
)