react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

V4 -- Provide sub generator to insert new env #278

Closed sthzg closed 7 years ago

sthzg commented 8 years ago

I'd like to propose the following and am interested in feedback if that would be considered useful.

yo react-webpack:setup:newenv <env_name>
# writes config/webpack/<env_name>.js
# adds export to config/webpack/index.js
# writes src/config/<env_name>.js
# possibly writes to some other places I forgot about right now

Progress

Supported options (future iterations):

Functionality In the initial PR is kept simple to provide quicker integration. Further iterations can provide various finer updates, e.g.

--buildable    adds a build:<env_name> run script to package.json
--servable     adds a serve:<env_name> run script to package.json

Motivation:

In many projects I add one or more additional envs, e.g. a lib env that builds various component chunks to separate es5-artifacts.

File Contents:

The files it creates are bare-bones, don't make any assumptions, and just provide the boilerplate for users to insert their env configuration, whatever this might be.

UI:

The namespace react-webpack:setup:<foo> is chosen so that we can add arbitrary setup tools in the future when the use case arises. ATM I don't know if Yeoman can by default resolve a third level, so if that doesn't work easily I would propose yo react-webpack:setup-<foo> instead (note the hypen - instead of the colon :.

weblogixx commented 8 years ago

Sounds like a good idea 👍

sthzg commented 7 years ago

@weblogixx I've pushed the initial version for this feature in https://github.com/react-webpack-generators/generator-react-webpack/commit/68d85547c59c26a65c4da485f682c9b21f0eb5e2. I'd postpone additional features (e.g. the options proposed in the initial ticket) to a later time. IMO it is valuable even in this very basic state. Let me know what you think.

weblogixx commented 7 years ago

Hi @sthzg, sorry for the late reply, I was on vacation. This seems really nice to me. 👍 for also adding it to the global config loader. I think this is fine and should be integrated for v4.

sthzg commented 7 years ago

@weblogixx no worries, I hope you had a great vacation. I want to make the first version of the code insertion still a bit more resilient and will then merge it into V4.

sthzg commented 7 years ago

Initial functionality provided with #308