Vuetify-module: v1.0.0-beta.0 theme options themeCache & minifyTheme do not work

Created on 6 Jun 2019  路  11Comments  路  Source: nuxt-community/vuetify-module

Repo: https://github.com/csheppard/nuxt-vuetify-2/tree/vuetify-module

Specifying themeCache results in a server error:

options.themeCache.get is not a function

minifyTheme also does not seem to work, the generated theme CSS still has whitespace.

Most helpful comment

@csheppard you need to use a plugin for this

// plugins/vuetify-theme-cache.js
import LRU from 'lru-cache'

const themeCache = new LRU({
  max: 10,
  maxAge: 1000 * 60 * 60 // 1 hour
})

export default (ctx) => {
  ctx.app.vuetify.framework.theme.options.themeCache = themeCache
}
// nuxt.config.js
modules: [
  '@nuxtjs/vuetify'
],

plugins: [
  '~/plugins/vuetify-theme-cache.js'
]

All 11 comments

@csheppard Looks like a Vuetify issue, is it still reproducible with our last beta version of the module ?

@csheppard you need to use a plugin for this

// plugins/vuetify-theme-cache.js
import LRU from 'lru-cache'

const themeCache = new LRU({
  max: 10,
  maxAge: 1000 * 60 * 60 // 1 hour
})

export default (ctx) => {
  ctx.app.vuetify.framework.theme.options.themeCache = themeCache
}
// nuxt.config.js
modules: [
  '@nuxtjs/vuetify'
],

plugins: [
  '~/plugins/vuetify-theme-cache.js'
]

Good catch @ricardogobbosouza , this is needed cause of some serialization of Nuxt configuration options I guess ?

@kevinmarrec yes, because of the serialization

@csheppard

With next module release version (1.0.0) you'll be able to use @ricardogobbosouza snippet and replace ctx.app.vuetify.framework by ctx.$vuetify as shorten path.

export default (ctx) => {
  ctx.$vuetify.theme.options.themeCache = themeCache
}

Great work, the plugin method is definitely needed as I had to stop using this module and go manual again as editing nuxt.config.js (adding icons/colour edits) requires full rebuild everytime.

@kevinmarrec can closed?

@csheppard Indeed it needs full rebuild when updating module options, we may implement a feature like providing a path (string) to the Vuetify options so it registers & watch it like a plugin to prevent these full rebuilds.

@kevinmarrec maybe we should reopen this with this option you mentioned above :thinking:

@ricardogobbosouza I would say new issue tagged as feature request

Was this page helpful?
0 / 5 - 0 ratings