I've been trying to create an Angular UI Library that is included in an Angular Application which is then to be used as the clientlib within AEM. But the process of building the application and then moving it to clientlibs is changing the import path within the CSS.
The UI library contains fonts that are packaged up along with the SCSS pointing to those relative font locations.
libs/ui/src/styles/fonts.scss
@2375939-face {
font-family: 'FF Mark Pro';
font-style: normal;
font-weight: typography.$weight-regular;
src: url('../assets/fonts/FF-Mark-Regular.woff2') format('woff2'),
url('../assets/fonts/FF-Mark-Regular.woff') format('woff');
}
libs/ui/src/assets/fonts/FF-Mark-Regular.woff
libs/ui/src/assets/fonts/FF-Mark-Regular.woff2
Now to include this scss I have added it as a separate style bundle in the angular.
"styles": [
"apps/aem-clientlib/src/styles.scss",
{
"input": "libs/eds-base/src/styles/fonts.scss",
"bundleName": "fonts"
}
]
Annoyingly the way angular works is that it then rolls all the included assets in the scss file and dumps them in the root of the project, adds the <link> with the each of the css files in the index.html, and the paths in the css are now relative to those files.
<link
rel="stylesheet"
href="fonts.94e3d1271343934c.css"
crossorigin="anonymous"
integrity="sha384-W9tDdK7sgsqfsHpjuDpFWdqEEfpAg9+IhEBTnixGpM4EiLKBV5Q5oQkkQqg/VhF9"
media="print"
onload="this.media='all'"
/>
dist/aem-clientlib/fonts.####.css
@2375939-face {
font-family: FF Mark Pro;
font-style: normal;
font-weight: 400;
src: url(FF-Mark-Regular.1ae3f8c88007c98e.woff2) format("woff2"),
url(FF-Mark-Regular.77d17aff63c2ea14.woff) format("woff");
}
Now this all works fine, but the issue comes when I try to use the
aem-clientlib-generator to move the files to the aem application, the files split and then the link between the css and fonts is broken.
Is there a way to correctly import the scss so that the paths are then changed to point to the resources folder?