Replies: 8 comments 3 replies
-
|
I was just about to ask something similar. I don't want to fork the entire One answer is to make a second generator/executor that you just run after. In your case you can generate the React app then build another generator (or possibly executor) to do more work and just target that project. Adding more steps to automation isn't great as that means more potential for human error. It is the short fix for now though I suppose. |
Beta Was this translation helpful? Give feedback.
-
|
Here you can see an example of how a generator would use another generator. The For learning more about generators/executors implementations, I suggest you go through the code in the official NX plugins, you'll see a lot of examples of what can be done. |
Beta Was this translation helpful? Give feedback.
-
|
The following solution is not perfect, but maybe it helps https://github.com/rfprod/nx-ng-starter/tree/main/tools/generators/client-feature - this is how a custom client feature library can be generated. |
Beta Was this translation helpful? Give feedback.
-
|
I'm in the same boat as @Erazihel. Is there any documented way to extend react generator and modify the files? (I tried going through docs, videos but could not understand the way to achieve the same). |
Beta Was this translation helpful? Give feedback.
-
|
Also faced with the problem of inheritance of standard generators. Therefore, there are 3 options:
|
Beta Was this translation helpful? Give feedback.
-
|
HI! I think this coukd help #5125 (comment)
|
Beta Was this translation helpful? Give feedback.
-
|
This is a basic example of how to extend a custom generator with another generator import { formatFiles, getProjects, Tree } from '@nx/devkit';
import { InitGeneratorSchema } from './schema';
import { libraryGenerator as angularLibraryGenerator } from '@nx/angular/generators';
export async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
const projects = getProjects(tree);
if (!projects.has(options.name) {
await angularLibraryGenerator(tree, {
name: options.name,
});
}
await formatFiles(tree);
}
export default initGenerator; |
Beta Was this translation helpful? Give feedback.
-
|
In case it can help someone, I made a gist showing how to create a generator that extends |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there 👋
I'd like to extend the
@nrwl/react:appgenerator in order to generate applications that perfectly match our needs inside our monorepo.I'm currently importing the
applicationGeneratormethod from@nrwl/reactinside my generator. The thing is, in order to make it work, I have to duplicate a lot of content from theschema.jsonfrom theapplicationgenerator.I'd also like to know if updating the content of the generated file by the
applicationgenerator is something feasible or not? I must say that the documentation on the Nx website is poor on that precise matter.Thank you for your responses.
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions