This PR adds a `@nx/vite:setup-paths-plugin` generator to add
`nxViteTsPaths` plugin to all vite config files in the workspace. This
can also be used with init/add as follows:
```shell
nx add @nx/vite --setupPathsPlugin
nx g @nx/vite:init --setupPathsPlugin
```
Which takes a config such as:
```ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
})
```
And updates it to:
```ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
export default defineConfig({
plugins: [react(), nxViteTsPaths()],
})
```
Taking into account ESM (default) and CJS (deprecated).
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
## Current Behavior
<!-- This is the behavior we have today -->
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes #
26 lines
878 B
JSON
26 lines
878 B
JSON
{
|
|
"name": "setup-paths-plugin",
|
|
"factory": "./src/generators/setup-paths-plugin/setup-paths-plugin",
|
|
"schema": {
|
|
"cli": "nx",
|
|
"title": "Sets up the nxViteTsPaths plugin.",
|
|
"description": "Updates vite config files to enable support for workspace libraries via the nxViteTsPaths plugin.",
|
|
"$id": "setup-paths-plugin-vite-plugin",
|
|
"type": "object",
|
|
"properties": {
|
|
"skipFormat": {
|
|
"description": "Skip formatting files.",
|
|
"type": "boolean",
|
|
"default": false
|
|
}
|
|
},
|
|
"presets": []
|
|
},
|
|
"description": "Sets up the nxViteTsPaths plugin to enable support for workspace libraries.",
|
|
"implementation": "/packages/vite/src/generators/setup-paths-plugin/setup-paths-plugin.ts",
|
|
"aliases": [],
|
|
"hidden": false,
|
|
"path": "/packages/vite/src/generators/setup-paths-plugin/schema.json",
|
|
"type": "generator"
|
|
}
|