Update full-stack AEM project to use front-end pipeline update-project-enable-frontend-pipeline
In this chapter, we make config changes to the WKND Sites project to use the front-end pipeline to deploy JavaScript and CSS, rather than requiring a complete full-stack pipeline execution. This decouples the development and deployment lifecycle of front-end and back-end artifacts, allowing for a more rapid, iterative development process overall.
Objectives objectives
- Update full-stack project to use the front-end pipeline
Overview of configuration changes in the full-stack AEM project
Prerequisites prerequisites
This is a multi-part tutorial and it is assumed that you have reviewed the ‘ui.frontend’ Module.
Changes to the full-stack AEM project
There are three project-related config changes and a style change to deploy for a test run, thus in total four specific changes in the WKND project to enable it for the front-end pipeline contract.
-
Remove the
ui.frontendmodule from full-stack build cycle- In, the WKND Sites Project 's root
pom.xmlcomment the<module>ui.frontend</module>submodule entry.
code language-xml ... <modules> <module>all</module> <module>core</module> <!-- <module>ui.frontend</module> --> <module>ui.apps</module> ...- And comment related dependency from the
ui.apps/pom.xml
code language-xml ... <!-- ====================================================================== --> <!-- D E P E N D E N C I E S --> <!-- ====================================================================== --> ... <!-- <dependency> <groupId>com.adobe.aem.guides</groupId> <artifactId>aem-guides-wknd.ui.frontend</artifactId> <version>${project.version}</version> <type>zip</type> </dependency> --> ... - In, the WKND Sites Project 's root
-
Prepare the
ui.frontendmodule for the front-end pipeline contract by adding two new webpack config files.- Copy the existing
webpack.common.jsaswebpack.theme.common.js, and changeoutputproperty andMiniCssExtractPlugin,CopyWebpackPluginplugin config params as below:
code language-javascript ... output: { filename: 'theme/js/[name].js', path: path.resolve(__dirname, 'dist') } ... ... new MiniCssExtractPlugin({ filename: 'theme/[name].css' }), new CopyWebpackPlugin({ patterns: [ { from: path.resolve(__dirname, SOURCE_ROOT + '/resources'), to: './theme' } ] }) ...- Copy the existing
webpack.prod.jsaswebpack.theme.prod.js, and change thecommonvariable’s location to the above file as
code language-javascript ... const common = require('./webpack.theme.common.js'); ...note note NOTE The above two ‘webpack’ config changes are to have different output file and folder names, so we can easily differentiate between clientlib (Full-stack) and theme generated (front-end) pipeline front-end artifacts. As you guessed, the above changes can be skipped to use existing webpack configs too but the below changes are required. It’s up to you how you want to name or organize them. - In the
package.jsonfile, make sure, thenameproperty value is the same as the site name from the/confnode. And under thescriptsproperty, abuildscript instructing how to build the front-end files from this module.
code language-javascript { "name": "wknd", "version": "1.0.0", ... "scripts": { "build": "webpack --config ./webpack.theme.prod.js" } ... } - Copy the existing
-
Prepare the
ui.contentmodule for the front-end pipeline by adding two Sling configs.- Create a file at
com.adobe.cq.wcm.core.components.config.HtmlPageItemsConfig- this includes all the front-end files that theui.frontendmodule generates under thedistfolder using webpack build process.
code language-xml ... <css jcr:primaryType="nt:unstructured" element="link" location="header"> <attributes jcr:primaryType="nt:unstructured"> <as jcr:primaryType="nt:unstructured" name="as" value="style"/> <href jcr:primaryType="nt:unstructured" name="href" value="/theme/site.css"/> ...note tip TIP See the complete HtmlPageItemsConfig in the AEM WKND Sites project. - Second the
com.adobe.aem.wcm.site.manager.config.SiteConfigwith thethemePackageNamevalue being the same as thepackage.jsonandnameproperty value andsiteTemplatePathpointing to a/libs/wcm/core/site-templates/aem-site-template-stub-2.0.0stub path value.
code language-xml ... <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured" siteTemplatePath="/libs/wcm/core/site-templates/aem-site-template-stub-2.0.0" themePackageName="wknd"> </jcr:root> ...note tip TIP See, the complete SiteConfig in the AEM WKND Sites project. - Create a file at
-
A theme or styles change to deploy via front-end pipeline for a test run, we are changing
text-colorto Adobe red (or you can pick your own) by updating theui.frontend/src/main/webpack/base/sass/_variables.scss.code language-css $black: #a40606; ...
Finally, push these changes to your program’s Adobe git repository.
Caution - Enable Front End Pipeline button
The Rail Selector 's Site option shows the Enable Front End Pipeline button upon selecting your site root or site page. Clicking Enable Front End Pipeline button will override the above Sling configs, make sure you do not click this button after deploying above changes via Cloud Manager pipeline execution.
If it is clicked by mistake, you have to rerun the pipelines to make sure that front-end pipeline contract and changes are restored.
Congratulations! congratulations
Congratulations, you have updated the WKND Sites project to enable it for the front-end pipeline contract.
Next steps next-steps
In the next chapter, Deploy using the Front-End Pipeline, you will create and run a front-end pipeline and verify how we moved away from the ‘/etc.clientlibs’ based front-end resources delivery.