Skip to content

Commit db8b35a

Browse files
committed
chore: update readme
1 parent 95f0cfa commit db8b35a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,45 @@ export const plugins: Config['plugins'] = [
390390
]
391391
```
392392

393+
### addVitePlugin
394+
395+
Register a Vite plugin to the `vite.config.ts` file.
396+
397+
> [!IMPORTANT]
398+
> This codemod expects the `vite.config.ts` file to exist and must have the `export default defineConfig` function call.
399+
400+
```ts
401+
const transformer = new CodeTransformer(appRoot)
402+
const imports = [
403+
{
404+
isNamed: false,
405+
module: '@vitejs/plugin-vue',
406+
identifier: 'vue'
407+
},
408+
]
409+
const pluginUsage = 'vue({ jsx: true })'
410+
411+
try {
412+
await transformer.addVitePlugin(pluginUsage, imports)
413+
} catch (error) {
414+
console.error('Unable to register vite plugin')
415+
console.error(error)
416+
}
417+
```
418+
419+
Output
420+
421+
```ts
422+
import { defineConfig } from 'vite'
423+
import vue from '@vitejs/plugin-vue'
424+
425+
export default defineConfig({
426+
plugins: [
427+
vue({ jsx: true })
428+
]
429+
})
430+
```
431+
393432
### addPolicies
394433
Register AdonisJS bouncer policies to the list of `policies` object exported from the `app/policies/main.ts` file.
395434

0 commit comments

Comments
 (0)