Import Plugin Assets


We are using Sage 10dev and are trying to Import JS/CSS assets from Wordpress plugins.
Is there a best approach how to achieve this?

We tried
import '../../../../../plugins/theplugin/assets/js/dist/front.min';
But when compiling we get following error:
Module not found: Error: Can’t resolve ‘@babel/runtime/helpers/typeof’ in ‘/volume1/Development/site-2020/web/app/plugins/theplugin/assets/js/dist’

Thanks for any help on this

What’s the reason for doing this? It is going to be difficult and cause you a lot of problems.

We use Barbara.js for page loading. The plug-in adds the assets outside the data container, so the JS is not loaded on all pages. I could inject on page load, but thought it would be easier to just add the JS code via webpack to the main JS file.

Or is there any other approach to include plugin assets with the webpack workflow?

I don’t know of a good way to get that stuff into the webpack workflow. I’m not sure of a generalized way you could get WordPress plugins working w/ Barba, not least because they can get fairly esoteric. For a known set of plugins, you could feasibly do something like de-registering scripts/styles and then manually printing them out inside the container so they would get refreshed when the “page” changes.

Yeah, this is what I had in mind. Just thought there would be a „cleaner“ way.
But thanks!