Hi Folks I am new to …
Hi Folks,
I am new to Nx
and I am in the process of creating some custom schematics for my workspace. Specifically, I want help in
running custom plugins
that contain schematics
that is local to my workspace.
- I have a created a sample workspace: https://github.com/niki4810/myorg
Details:
- I created a custom schematic in
tools
usingnx generate @nrwl/workspace:workspace-schematic
- My schematic is a simple one that extends
@nrwl/react
that disables styles and always makes the libpublishable
: https://github.com/niki4810/myorg/blob/master/tools/schematics/custom-react/index.ts#L7-L8 - I am able to run this via
nx workspace-schematic custom-react
(This Works!!!)
However, I would like to have this part of a plugin so:
- I generated a custom plugin via
nx generate @nrwl/nx-plugin:plugin
- I then created a custom schematic via
nx generate @nrwl/nx-plugin:schematic
- And did what I did earlier with this newly created schematic: https://github.com/niki4810/myorg/blob/master/libs/custom-react/src/schematics/library/schematic.ts#L8-L9
I am not sure how to run this custom schematic that is part of my lib/custom-react
plugin library.
I checked the docs: https://nx.dev/react/plugins/nx-plugin/overview and I could not find a way to run this locally.
Can someone please help me. Thanks!
Responses:
I actually ran into this recently and would like to know as well.
One obvious solution would be to publish your plugin to npm or a private registry and then add it to your package.json, but that seems overkill for sure.
There’s no easy way to run an nx plugin within a repo, without actually publishing it. This functionality could be added though :thinking_face:
Thanks, Jon, nx workspace-schematic
works great and would satisfy my current need. Except that:
• It would be nice to use nx list <plugin>
to see the list of schematics
• And use the regular nx generate <plugin>:<schematic>
command pattern (one less command to remember :slightly_smiling_face: )
Just a couple of thoughts.
I ran into this. The docs default to a brand new workspace for plugin creation, but then say:
> If you do not want to create a new workspace, install the @nrwl/nx-plugin
dependency in an already existing workspace with npm or yarn. Then run nx g @nrwl/nx-plugin:plugin [pluginName]
.
But don’t mention how to run them it seems.
on https://nx.dev/react/plugins/nx-plugin/overview
The plugins themselves aren’t able to be ran within their workspace. They’re intended to be published and shared across orgs
A feature request could be created on github and I could carve out some time to investigate
That would be awesome . If someone else doesn’t get to it before me I’ll try to write up a feature request later this week.
created a github feature request: https://github.com/nrwl/nx/issues/3231 for this. Also liked this slack thread in the description.
Thanks!
Relevant office hours q https://youtu.be/ChQsqGheQzc?t=1124