Question regarding the creation of npm packages and the ability to dynamically request resources from one package in another.
Imagine I have a collection of images in package A, along with JavaScript logic to fetch them:
// Inside package B
import Component from 'pkg-a'
Component.getImage('foo')
I build this using vite/webpack and then use package B, which has package A listed in its dependencies in 'package.json'
Typically, the build tool will only include the specified images directly into the /dist folder of package A
However, my goal is to:
- Have all images in the /dist folder - this can be achieved by using the /public folder;
- Enable package A to accept arguments specifying an image name and return the correct image dynamically from its dist folder - unsure if this is feasible;
Is it possible to request just one image from package A, or do I need to encode all images in BASE64 format inside .es.js files (which increases file size by 30%) within package A?