TwicPics / components

A Web component library that brings the power of TwicPics to your favorite web framework.
MIT License
53 stars 2 forks source link

Feature request: support runtime domain config #71

Open existe-deja opened 10 months ago

existe-deja commented 10 months ago

Hi,

It would be nice to support runtime configuration instead of build only. I manage a project with a staging domain and I have to build it separately to handle different domains.

edit: I use the nuxt 3 component module

mbgspcii commented 10 months ago

Hi @existe-deja.

In fact, TwicPics Nuxt3 module already uses runTimeConfig.

This is the plugin.js used in our Nuxt3 module:

image

Now, in a Nuxt3 project we configure the module like this:

Capture d’écran 2023-09-28 à 17 49 20

(with a default config)

And then we can add an .env file to our project like this:

NUXT_PUBLIC_TWICPICS_DOMAIN="https://demo.twic.it"
NUXT_PUBLIC_TWICPICS_ANTICIPATION=50
NUXT_PUBLIC_TWICPICS_STEP=100

We we run the project

Capture d’écran 2023-09-28 à 17 52 23

we actually use the domain as configured in the .env file.

But I don't think that's meets your needs. In fact, if you modify the .env file, you'll have to redo a Nuxt dev (or build) so that the modifications are taken into account.

To be honest, I don't see how you can modify your environment variables once the project has been built.

Could you clarify this for me so that we can take a closer look?

Looking forward to reading you.

Miguel

existe-deja commented 9 months ago

Hi, thanks for your answer. I can use the NUXT_PUBLIC_TWICPICS_DOMAIN env variable and it works fine even after a build. Thing is twicpics nuxt3 module require a domain option even if i set one in the with the env variable.

Can you make it optional?