primefaces / primevue-nuxt-module

MIT License
70 stars 11 forks source link

Pass object to `importPT` alongside with path #64

Closed twisteriokovel closed 2 months ago

twisteriokovel commented 3 months ago

I use the Primevue + Nuxt 3 + Tailwind for my project. I am working on my custom Nuxt 3 module which is responsible for setting up the project's theme. This module has a default preset but I want to have the ability to override one of the components in this preset. I want to pass it as a parameter to my module in nuxt.config file

myModule: {
    preset
}

My preset is just the object that has for example one override for button

import button from './button'
export default {
  button
}

In my module I want to have the ability to do something like

async setup(_options, _nuxt) {
  const { preset } = _options
  const presetToUse = { ...defaultPreset, ...preset }

  await installModule('nuxt-primevue', {
     options: {
       unstyled: true,
     },
     importPT: {
       as: 'myPreset',
       from: presetToUse, // not possible right now
     }
  })
}

Is there any workaround for it?

mertsincan commented 2 months ago

Hi,

This is related to serializable definitions. Please see my comments; https://github.com/primefaces/primevue-nuxt-module/issues/6#issuecomment-1772954754

Exp;

import path from 'path';

export default defineNuxtConfig({
    modules: [
        'nuxt-primevue'
    ],
    primevue: {
        unstyled: true,
        importPT: { from: path.resolve(__dirname, './presets/lara/') }      //import and apply preset
    }
})

Best Regards,