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 #
48 lines
1.5 KiB
JSON
48 lines
1.5 KiB
JSON
{
|
|
"name": "init",
|
|
"factory": "./src/generators/init/init#initGeneratorInternal",
|
|
"schema": {
|
|
"cli": "nx",
|
|
"title": "Initialize Vite in the workspace.",
|
|
"description": "Initialize Vite in the workspace.",
|
|
"$id": "init-vite-plugin",
|
|
"type": "object",
|
|
"properties": {
|
|
"skipFormat": {
|
|
"description": "Skip formatting files.",
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"skipPackageJson": {
|
|
"description": "Do not add dependencies to `package.json`.",
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"setupPathsPlugin": {
|
|
"type": "boolean",
|
|
"description": "Updates vite config files to enable support for workspace libraries via the nxViteTsPaths plugin.",
|
|
"default": false
|
|
},
|
|
"keepExistingVersions": {
|
|
"type": "boolean",
|
|
"x-priority": "internal",
|
|
"description": "Keep existing dependencies versions",
|
|
"default": false
|
|
},
|
|
"updatePackageScripts": {
|
|
"type": "boolean",
|
|
"x-priority": "internal",
|
|
"description": "Update `package.json` scripts with inferred targets",
|
|
"default": false
|
|
}
|
|
},
|
|
"presets": []
|
|
},
|
|
"description": "Initialize Vite in the workspace.",
|
|
"aliases": ["ng-add"],
|
|
"hidden": true,
|
|
"implementation": "/packages/vite/src/generators/init/init#initGeneratorInternal.ts",
|
|
"path": "/packages/vite/src/generators/init/schema.json",
|
|
"type": "generator"
|
|
}
|