Redwood: Custom Generators

Created on 30 Jul 2020  路  2Comments  路  Source: redwoodjs/redwood

Let users override the default generator templates from their own code.

  • Add a command to copy existing generator to local codebase
  • Have generators look at the app's directory before defaulting back to package template

/cc @Burnsy

kinimprovement generators

Most helpful comment

So after having a quick conversation with rob, about how I was feeling that I felt like I was going faster by using the generators but then I was slowed down because I needed to customize the generators to fit the layout, customized table css etc.

Then I remembered the concept in gatsby called shadowing.

How I think shadowing the generators could work;

  1. RW CLI command to duplicate the generator file locally (ie to web/generators/)
  2. When The RW CLI Generator command is run it will check to see if the is a customized generator file and if not then load the default redwood generator file

I think it could work quite well as the customization would truly allow you to speed up as the layout would completely match what you need them for without having too much customization.

Also, Could you want to have multiple frontend generator files? 1 for login 2 for dashboard etc.

All 2 comments

So after having a quick conversation with rob, about how I was feeling that I felt like I was going faster by using the generators but then I was slowed down because I needed to customize the generators to fit the layout, customized table css etc.

Then I remembered the concept in gatsby called shadowing.

How I think shadowing the generators could work;

  1. RW CLI command to duplicate the generator file locally (ie to web/generators/)
  2. When The RW CLI Generator command is run it will check to see if the is a customized generator file and if not then load the default redwood generator file

I think it could work quite well as the customization would truly allow you to speed up as the layout would completely match what you need them for without having too much customization.

Also, Could you want to have multiple frontend generator files? 1 for login 2 for dashboard etc.

It'd be cool if it was possible to yarn add community generators.

At work, for example, in our React app, for every page (FooPage.tsx) we have a sass-file (FooPage.scss). It'd be really useful to be able to write a generator package that when generating a new page also generated an empty sass file and added the corresponding import to *Page.tsx. This generator package would then be published to our org on npm and easily installed in all of our (hypothetical) RW projects.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hemildesai picture hemildesai  路  4Comments

josteph picture josteph  路  3Comments

freddydumont picture freddydumont  路  3Comments

peterp picture peterp  路  4Comments

thedavidprice picture thedavidprice  路  3Comments