Skip to content

Commit

Permalink
Import blueprint based on string
Browse files Browse the repository at this point in the history
I'm guessing its runtime issues, but you need to import blueprints in the plugin. I'm certain this also has other implications for other imports.

Also updated the types to override the blueprint property to reflect this change
  • Loading branch information
Teranode committed Dec 13, 2022
1 parent a75e0cb commit b5a1e4b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nuxt-alt/vuetify",
"version": "1.0.6",
"version": "1.0.8",
"description": "An alternative module for setting up Vueitfy 3 with nuxt.",
"homepage": "https://github.com/nuxt-alt/vuetify",
"author": "Teranode",
Expand Down
8 changes: 3 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ModuleOptions } from './types';
import type { Nuxt } from '@nuxt/schema'
import { name, version } from '../package.json';
import { defineNuxtModule, addPluginTemplate, createResolver, addImports, addTemplate } from '@nuxt/kit';
import { defineNuxtModule, addPluginTemplate, createResolver, addImports } from '@nuxt/kit';
import vuetify from 'vite-plugin-vuetify'
import { defu } from 'defu'

Expand Down Expand Up @@ -45,7 +45,7 @@ export default defineNuxtModule({
// Vuetify plugin configuration
config.plugins = [
...(config.plugins || []),
vuetify(options.pluginOptions),
vuetify(options.pluginOptions) as typeof config.plugins,
]

config.define = {
Expand Down Expand Up @@ -74,9 +74,7 @@ export default defineNuxtModule({
addPluginTemplate({
src: resolve('./runtime/templates/plugin.mjs'),
filename: 'vuetify.plugin.mjs',
options: {
options: options.vuetifyOptions
}
options: options.vuetifyOptions
})

// Runtime
Expand Down
10 changes: 8 additions & 2 deletions src/runtime/templates/plugin.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { defineNuxtPlugin } from '#imports';
import { createVuetify } from '#vuetify';

const options = JSON.parse('<%= JSON.stringify(options) %>')
const opts = JSON.parse('<%= JSON.stringify(options) %>')

'<% if (options.blueprint) { %>'
import { <%= options.blueprint %> as blueprint } from 'vuetify/blueprints'
opts.blueprint = blueprint
'<% } %>'

export default defineNuxtPlugin(nuxtApp => {
const vuetify = createVuetify(options)
const vuetify = createVuetify(opts)

nuxtApp.vueApp.use(vuetify)

return {
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ interface Options {
stylesTimeout?: number;
}

export interface NuxtVuetifyOptions extends Omit<VuetifyOptions, 'blueprint'> {
blueprint: 'md1' | 'md2' | 'md3'
}

export interface ModuleOptions {
vuetifyOptions?: VuetifyOptions
vuetifyOptions?: NuxtVuetifyOptions
pluginOptions?: Options
}

declare module '#app' {
interface NuxtApp {
$vuetify: VuetifyOptions;
$vuetify: NuxtVuetifyOptions;
}
}

Expand Down

0 comments on commit b5a1e4b

Please sign in to comment.