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

Extending default configuration #15

Closed
rkostrzewski opened this issue May 20, 2017 · 6 comments
Closed

Extending default configuration #15

rkostrzewski opened this issue May 20, 2017 · 6 comments

Comments

@rkostrzewski
Copy link
Collaborator

Hi there,
incredible work on the cli & tooling configuration. However, even the greatest config does not meet all needs and thus the question - Do you have plans on allowing users to extend default configuration?

Some use cases as a conversation starting point:

  • large part of the community likes to follow components & containers folder structure when working with redux and aliasing those in webpack helps with large import paths (i.e.import Header from '../../../../components/Header) - normally this would be done via babel plugin or webpack alias,
  • Service Workers are great because they can cache static files but they are even better because they allow runtime caching - this would require changing plugin
  • when server side rendering <script defer /> might be better than <script async /> - again changing plugin config
  • a new cool kid appears around the block (e.g. prepack) and users want to use it - adding new plugin and in order

AFAIK create-react-app have chosen not to allow changing configuration. However they provide eject functionality which generates all config files (docs).
The only problem with this is that once ejected there's no easy way with keeping ejected config in sync with create-react-app.

@vitormalencar
Copy link
Contributor

I also think it would be a good feature, this would give much more flexibility to the project.

@developit
Copy link
Member

developit commented May 20, 2017

I would like to allow configuration extension by looking for a preact.config.js, which can export a function that mutates the generated webpack configuration however it pleases.

For plugin ordering we might need to do something like proxy plugin instantiation and annotate each plugin instance with a human-readable name so that they can be change later.

@rkostrzewski
Copy link
Collaborator Author

Do you need help with that? I'll be happy to provide a PR.

Maybe preact.config.js could be written in ES6 and name property would be enough? As in:

config.plugins.map(p =>p.name)
/* ['CommonChunksPlugin', 'ExtractTextPlugin', 'ProvidePlugin'] */

Hopefuly it will 😄

@developit
Copy link
Member

^ hopefully. That or we provide a helper to get the name from any plugin in the plugins array based on the constructor name.

Writing it in ES6 is fine, I think preact-cli already includes babel-register in order to do prerendering. I left a comment here with more thoughts on the idea: #37 (comment)

@kanzelm3
Copy link

kanzelm3 commented Jun 23, 2017

I would love to have this ability as well. I want to customize postcss plugins so I can do this: https://github.com/react-toolbox/react-toolbox#settings-configuration-variables-in-javascript

@rkostrzewski
Copy link
Collaborator Author

Custom configuration support has landed in 1.3.0.

@rkostrzewski rkostrzewski removed their assignment Jun 29, 2017
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

4 participants