[React] Support static CRA assets #61
Comments
I managed to get the static assets over to AEM by tweaking clientlib.config.js:
The problem is that in the CSS files, the URL of the assets is something like: however in AEM we require that the URL get rewritten to something like |
Raised wcm-io-frontend/aem-clientlib-generator#14 which will be required in order to solve this. |
@ittaibaratz another alternative would be to add an additional webpack module to build process to rewrite the compiled CSS before using clientlib-generator to move it into a client-library... |
I think it's cleaner to rewrite only in the AEM folder, this way the built scripts inside the react project's build folder will still work independently. I have created a PR in aem-clientlib-generator which will enable this. If they don't accept, we can do the rewriting after the clientlib was generated inside the AEM folder - This is very easy to do with replace-in-file |
@ittaibaratz Thanks for taking care of this issue and driving the discussion. |
I have closed the PR - Will look for a cleaner alternative which will support both CSS and JS. |
I have done some research and here are the possible options to support CRA static assets within AEM:
|
For my own app, I've decided to use react-scripts-rewired which is the simplest solution to allow webpack override. Here are the steps I've taken. These make sure all assets work in AEM when referenced in both CSS and JS: (Note PROJECT should be replaced with actual project name)
|
hi @ittaibaratz
would you know what might be the issue here, did you also face the same issue? Will appreciate your reply. Thanks |
The Create React App used by this archetype will create JS, CSS and static assets under the build folder:
However, aem-clientlib-generator used by this library will only copy the JS and CSS files.
As a result, when static resources are used by the app (Fonts, background images, etc) - They will be broken in AEM.
The text was updated successfully, but these errors were encountered: