Skip to content

Commit 833132e

Browse files
authored
feat: allow ignoring directives (#242)
1 parent 210eeec commit 833132e

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

docs/.vitepress/theme/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Theme from 'vitepress/theme'
1+
import type { Theme } from 'vitepress'
2+
import DefaultTheme from 'vitepress/theme'
23
import { inBrowser } from 'vitepress'
34
import VuetifyLayout from './VuetifyLayout.vue'
45

@@ -11,6 +12,6 @@ if (inBrowser)
1112
import('./pwa')
1213

1314
export default {
14-
...Theme,
15+
extends: DefaultTheme,
1516
Layout: VuetifyLayout,
16-
}
17+
} satisfies Theme

docs/guide/globals/directives.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ By default, the module will not register any Vuetify directive. If you need to r
88

99
You can register all the directives or only the ones you need: check the [directives definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L91-L92).
1010

11+
## Ignore directives <Badge type="tip" text="from v0.15.1" />
12+
13+
If you want to ignore some directives, you can use the `moduleOptions.ignoreDirectives` option. The module will configure the Vuetify Vite Plugin to [ignore](https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#ignoring-components-or-directives) the directives you specify.
14+
1115
## Examples
1216

1317
### Registering all the directives

docs/guide/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ export interface MOptions {
124124
* @default true
125125
*/
126126
includeTransformAssetsUrls?: boolean | Record<string, string[]>
127+
/**
128+
* Directives Vuetify Vite Plugin should ignore.
129+
*
130+
* @since v0.15.1
131+
*/
132+
ignoreDirectives?: DirectiveName | DirectiveName[]
127133
/**
128134
* Vuetify SSR client hints.
129135
*

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ export interface MOptions {
255255
* @default true
256256
*/
257257
includeTransformAssetsUrls?: boolean | Record<string, string[]>
258+
/**
259+
* Directives Vuetify Vite Plugin should ignore.
260+
*
261+
* @since v0.15.1
262+
*/
263+
ignoreDirectives?: DirectiveName | DirectiveName[]
258264
/**
259265
* Vuetify SSR client hints.
260266
*

src/utils/configure-vite.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Nuxt } from '@nuxt/schema'
22
import defu from 'defu'
3+
import type { Options } from '@vuetify/loader-shared'
34
import { vuetifyStylesPlugin } from '../vite/vuetify-styles-plugin'
45
import { vuetifyConfigurationPlugin } from '../vite/vuetify-configuration-plugin'
56
import { vuetifyIconsPlugin } from '../vite/vuetify-icons-configuration-plugin'
@@ -41,7 +42,17 @@ export function configureVite(configKey: string, nuxt: Nuxt, ctx: VuetifyNuxtCon
4142
viteInlineConfig.vue.template.transformAssetUrls = transformAssetUrls
4243
}
4344

44-
viteInlineConfig.plugins.push(vuetifyImportPlugin({}))
45+
// fix #236
46+
const vuetifyImportOptions: Options = {}
47+
const ignoreDirectives = ctx.moduleOptions.ignoreDirectives
48+
if (ignoreDirectives) {
49+
const ignore = Array.isArray(ignoreDirectives)
50+
? ignoreDirectives
51+
: [ignoreDirectives]
52+
vuetifyImportOptions.autoImport = { ignore }
53+
}
54+
55+
viteInlineConfig.plugins.push(vuetifyImportPlugin(vuetifyImportOptions))
4556
viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles: ctx.moduleOptions.styles }, ctx.logger))
4657
viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(ctx))
4758
viteInlineConfig.plugins.push(vuetifyIconsPlugin(ctx))

src/vite/vuetify-import-plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { extname } from 'node:path'
22
import { pathToFileURL } from 'node:url'
33
import type { Plugin } from 'vite'
4-
import { type Options, generateImports } from '@vuetify/loader-shared'
4+
import type { Options } from '@vuetify/loader-shared'
5+
import { generateImports } from '@vuetify/loader-shared'
56
import { parseQuery, parseURL } from 'ufo'
67
import { isAbsolute } from 'pathe'
78
import destr from 'destr'

0 commit comments

Comments
 (0)