johannschopplich / kirbyup

🆙 Official bundler for Kirby Panel plugins
https://kirbyup.getkirby.com
MIT License
51 stars 3 forks source link

Weird behavior with index.php in /public folder #47

Closed lassereinboeng closed 4 months ago

lassereinboeng commented 5 months ago

Hi Johann!

First things first: Thank you for your work on kirbyup 🙏

Today I am experiencing some weird kirbyup behaviour and wanted to share it with you. Following this cookbook recipe I wanted to create a monolithic plugin setup with my plugin's index.php as the "root" index.php. As starting point I use the panel pluginkit. As I am using Herd for development and generally prefer public folder installations anyway, I thought it would be smart to put the index.php for Kirby in the /public folder and have my plugin's index.php in the project root.

Now, when I run kirbyup src/index.js, it copies the index.php from the /public folder into the root and thus replaces my plugin's index.php (everytime I run the build or dev script 😅). Is this expected behaviour and have I missed something in the docs or is this not expected behaviour of kirbyup? I can share my repository and/or structure with you, if it helps.

Thank you very much and have a great day :-) Lasse

lassereinboeng commented 5 months ago

Hi Johann!

Okay, today I learned that Vite automatically copies the /public folder to the /outDir (in this case my project root). So, Vite just copied my whole /public folder into the project root 😅 The feature can be disabled by putting

vite: {
    build: {
      copyPublicDir: false,
    },
  },

into the kirbyup.config.ts. I don't know if this might be interesting for other people trying to build a plugin within a monolithic public folder installation, but maybe a small hint in the kirbyup docs might help? :-)

Have a great weekend! Lasse

johannschopplich commented 4 months ago

Hi Lasse! Thanks for reporting this as well as solving this. Seems like this solution can be safely provided by kirbyup by default. I've never used the monolithic plugin setup, only with a playground folder setup. I wasn't aware of this problem until you reported it!