andrefelipe / vite-php-setup

Example on how to run Vite on traditional PHP sites
https://github.com/vitejs/vite
358 stars 52 forks source link

Purpose of "base" option in config #7

Closed countfak closed 2 years ago

countfak commented 2 years ago

Hi,

great starter, thank you. I'm using this with wordpress.

This isn't really an issue, but a question: I cannot understand the purpose of the "base" option inside the vite configuration file: if I remove it (and by doing so I always use the default '/'), it works the same, both in development and prodiction, so it looks like that I don't have to specify the dist folder there whenever I am in production, making the APP_ENV=development assignment in the package.json file useless as well.

What am I missing?

andrefelipe commented 2 years ago

Hello @countfak thanks!

If I am not mistaken, has to do with the paths of fonts and images you specify in CSS.

At the time, the best solution I got was using that combination base and root.

But please make some tests. If you find that base is not needed please let me know, I'd like to get rid of it and make the configuration cleaner.

countfak commented 2 years ago

Hey thanks for your fast reply!

Ok I understand. Since I'm using wordpress I'm afraid I won't be using assets like fonts and images directly from CSS, but I will do some tests and let you know.

andrefelipe commented 2 years ago

OK, thanks. If it helps I am putting together a WordPress template here https://github.com/wp-bond/boilerplate

You can use Vite to create the wp-editor.css and the a wp-admin color scheme too.

countfak commented 2 years ago

Hi,

I successfully integrated your Vite php setup in my WordPress custom starter theme and everything works like a charm, thanks again. As I said, I don't usually work with images or fonts directly in my css, so I don't really need to do that. With my current setup I no longer need the base option in config, because it just works without it in both dev and build. No need to do APP_ENV=development in package.json as well. Maybe in other use cases that option is needed, but that's not my case. Thank for your help.

andrefelipe commented 2 years ago

Thanks for the feedback @countfak !!