Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Breaks on apply a plugin only during development server phase #34

Open
ismaelocaramelo opened this issue Jun 19, 2020 · 0 comments

Comments

@ismaelocaramelo
Copy link

ismaelocaramelo commented Jun 19, 2020

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
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant