-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular MF with assets (images) in embedded app #697
Comments
Good point! For small SVGs I would just inline them in the compilation. When working with Less you have But, ... I see many issues. |
yes @cstefan thank, we inline small assets too. but we have problems with fonts, and big assets for now. No i have to postpone my research for now. |
anything webpack can process can be federated, images, css, side effects, the works. Im not sure if this is an angular specific issue |
I'm running into this issue as well. Angular typically loads assets against the base URL of its site, which is set with the Still trying to work on this, but I'm new to Webpack config stuff since Angular has handled it all for me in the past. |
Don't know how to handle angular specific. But in webpack the file-loader accepts a post transform option which you could use to infer the url internally Webpack usually figures it out with some parsing of document.currentScript |
Looks like there's a way to set this in webpack instead of depending on markup. Not sure how but someone told me it's possible. If so then we can get an at runtime base assignment |
Did anybody find a way to share static resources (images) between the remotes and the shell? |
You can declare shared assets from a library in the webpack config in the shared option of your ModuleFederationPlugin:
Just add this to both webpack configurations. It should then use the assets from your remote as well as your shell. This works if you have a monorepo and a shared assets library. |
I think I solved this problem relatively well, but I still want to explore a more convenient solution. You need to use the variable For example, to access an asset from a remote module, you can specify its path like this: declare const __webpack_public_path__: string;
@Component(...)
export class SomeComponent {
public publicPath = __webpack_public_path__; // here will be smth like `localhost:4201/`
}
<img [src]="publicPath + 'assets/some-asset.png'" />
To simplify your development, you can provide a variable in the exposed modules and make pipe that will build the correct link itself. <img [src]="'assets/some-asset.png' | localAsset" /> |
It's more question then issue.
Is there any practice on use images in html and css
cause by defaul if I use pathes like ../../assets/pic.png
when I open embedded app in shell app urls looking in shell app host e.g. localhost:4200 instead of localhost:4201 in angular example.
I would really appreciate any suggestions on that
The text was updated successfully, but these errors were encountered: