Closed Phillip9587 closed 3 weeks ago
v18.0.0-beta.3 provides support for Nx 18 Inferred Tasks
Please test it out and provide feedback.
To add the plugin add the following to your nx.json
:
{
"plugins": [
{
"plugin": "nx-stylelint/plugin",
"options": {
"targetName": "stylelint",
"extensions": ["css"]
}
}
]
}
targetDefaults can be configured e.g. --allow-empty-input
:
"targetDefaults": {
"stylelint": {
"options": {
"args": ["--allow-empty-input"]
}
}
}
I add the plugin to the nx.json file:
{
"plugin": "nx-stylelint/plugin",
"options": {
"targetName": "stylelint",
"extensions": ["scss"]
}
}
I'm also using this on targetDefaults:
"targetDefaults": {
"stylelint": {
"inputs": [
"default",
"{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?"
],
"cache": true,
"options": {
"args": [
"--allow-empty-input"
]
}
}
}
With this setup I can see the task being inferred in nx console with this description:
Created by nx/core/target-defaults from nx.json
but only for the libraries that have their own .stylelintrc
file.
It would be nice to have this task inferred independently of the lib having or not its own configuration file and using the rules defined at the workspaceRoot level.
Great job with this plugin guys ^^
@mateusgpereira Thanks for trying out the plugin.
I'm also using this on targetDefaults:
"targetDefaults": { "stylelint": { "inputs": [ "default", "{workspaceRoot}/.stylelintrc(.(json|yml|yaml|js))?" ], "cache": true, "options": { "args": [ "--allow-empty-input" ] } } }
You can remove the inputs here. The Inputs are infered by the plugin.
With this setup I can see the task being inferred in nx console with this description:
Created by nx/core/target-defaults from nx.json
but only for the libraries that have their own.stylelintrc
file. It would be nice to have this task inferred independently of the lib having or not its own configuration file and using the rules defined at the workspaceRoot level.
First, remove the stylelint targets from your project.json files. It looks like there is a stylelint target with the nx-stylelint:lint executor left. The stylelint target has to be infered from nx-stylelint/plugin
.
The libraries need a .stylelintrc file to identify them as projects that need Stylelint setup. However, you can add a simple .stylelintrc.json to your project root that extends the workspace root .stylelintrc file:
{
"extends": "../path/to/workspaceroot/.stylelintrc.json"
}
nx-stylelint v18 includes the experimental plugin. The generators do not support adding the plugin yet but it is planned once Nx exports the needed helpers from @nx/devkit
. Please test it out and provide feedback.
Support Nx Project Crystal / Inferred Tasks