How to host custom assets

Hi all,
I started developing my own custom plugin for OpenSearch. I need the plugin to display some custom images in the front-end and those static files need to be delivered inside the plugin build.

I found some post on Kibana forum, but looks like it is outdated. Adding graphic assets to plugins - Elastic Stack / Kibana - Discuss the Elastic Stack

I generated my plugin with generate_plugin.js script. I’m running Dashboard v 3.0.0.

Thank you in advance for any advice!

Your plugin’s setup() receives coreSetup which can be used to registerStaticDir.

Say your assets folder is in the same folder as the file that has setup() and you want to serve them you can do

setup(coreSetup) {
  const assetsLocation = path.resolve(__dirname, './assets');
  coreSetup.http.registerStaticDir('/assets/{path*}', assetsLocation);
}