Preact-cli: Extending default configuration

Created on 20 May 2017  路  6Comments  路  Source: preactjs/preact-cli

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

All 6 comments

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

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.

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 :smile:

^ 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: https://github.com/developit/preact-cli/issues/37#issuecomment-303383725

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

Custom configuration support has landed in 1.3.0.

Was this page helpful?
0 / 5 - 0 ratings