I am using SPA site in AEMaaCs
Currently we are hosting whole AEM code base in a single repository . AEM core, dispatcher ,ui.frontend, ui.apps everything in a single repository
Now when i try to run a frontend pipeline with below settings and build is failing
Should i separate frontend code into a different repository and use "Site Themes" to manage SPA components js files ?
If i need to convert my current ui.frontend folder into a "Site Themes" structure , how to do it ?
Please advice. Thankyou
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Vishnu9 ,
I checked the structure of the ui.frontend module for the SPA project. It looks like all JS and CSS files, including the main files, have a hash in their filenames. I suggest following the custom Webpack approach for the build to remove the hash from the main file and output the built code inside the dist folder, as needed for the FE pipeline.
Please refer to the WKND project without SPA enabled for an example: WKND GitHub - ui.frontend.
The clientlib.config.js file is only needed when you need to copy the generated files to the apps directory, so they can be included as part of the full-stack build. Since you're using the FE-only pipeline, this file is not required.
Creating a separate repository to convert the existing full-stack project to be compatible with the front-end pipeline is unnecessary. Instead, some modifications are needed in the existing project:
please refer to the official documentation: Enable Front-End Pipeline in AEM.
steps in that document are working for Wknd slightly project
Tested with SPA based wknd project ,
in this type of project it generates build folder insted of dist folder , because of this pipeline was failing.
So wrote code in clientlib.config.js to copy contents of build to dist then pipeline run was succesfull but how to integrate the js chunks and css chunks into HtmlPageItemsConfig .
And also these chunks have names like main.hash.css , main.hash.js,runtime.hash.js , etc
These hashes gets changed for every deployment , how to handle this dynamic nature of file names
@Vishnu9 ,
Glad to hear it’s working in your SPA project with the modifications you made!
In our project, we dynamically load the chunk files and handle the generation of these chunk files through our Webpack configuration.
output: {
filename: 'theme/js/[name].js',
chunkFilename: 'theme/resources/[name].[hash].js',
path: path.resolve(__dirname, 'dist'),
}
Since the chunk files are included dynamically when the main file loads, is there any need to load them separately in the HtmlPageItemsConfig?
my 'dist' folder has this type of structure and files .
Do i need to add sling configs HtmlPageItemsConfig and SiteConfig as mentioned in the given link ?
If those configs are needed , my main.hash.chunk.css and main.hash.chunk.js names changes for each modifications. So how to call these names in HtmlPageItemsConfig or calling these files on a page is done automatically ?
Do you have a main.js and main.css files in your SPA 'dist' folder ?
below is clientlib.config.js code .
Views
Replies
Total Likes
Hi @Vishnu9 ,
I checked the structure of the ui.frontend module for the SPA project. It looks like all JS and CSS files, including the main files, have a hash in their filenames. I suggest following the custom Webpack approach for the build to remove the hash from the main file and output the built code inside the dist folder, as needed for the FE pipeline.
Please refer to the WKND project without SPA enabled for an example: WKND GitHub - ui.frontend.
The clientlib.config.js file is only needed when you need to copy the generated files to the apps directory, so they can be included as part of the full-stack build. Since you're using the FE-only pipeline, this file is not required.
@Vishnu9 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies