Creating a nested plugin with independent backend for Grafana: build process help needed

I’m struggling to set up a nested datasource plugin with its own backend for Grafana. The official docs mention it’s possible but don’t explain how. I tried following the guide for app plugins with nested plugins but it messes up the folder structure.

When I add the pkg directory for the backend, the build process fails because plugin.json is in the wrong place. The src folder got renamed, breaking the usual plugin layout.

Does anyone know the right way to make a nested plugin with its own backend? How do I organize the files and run the build without errors? I’m really stuck here and could use some expert advice.

Thanks for any help!

I encountered a similar challenge when developing a complex Grafana plugin. One effective approach is to maintain the standard plugin structure while introducing a separate backend directory. Your folder structure could look like this:

root/
src/
backend/
plugin.json

To make this work, you’ll need to modify your build process. Create separate build scripts for the frontend and backend components. Then, use a tool like webpack to bundle everything together. Ensure your plugin.json correctly references the compiled backend binary.

Remember to update your TypeScript configuration to handle the new directory structure. This method allows for independent development of frontend and backend while maintaining Grafana’s expected plugin layout.

Hey Finn! That sounds like a real head-scratcher. :thinking: have you considered using a monorepo approach? It might help keep things organized. What specific errors are you getting during the build process? Maybe we could troubleshoot those together? I’m curious to hear more about your project - what kind of data are you trying to visualize?

hey finn, ive been there. its a real pain! have u tried keeping the standard plugin structure but adding a separate backend folder? like:

root/
src/
backend/
plugin.json

then modify ur build script to compile backend separately. might need some tweaking but could work. good luck!