AEM-React Setup
AEM-React Setup
Required software
• AEM
• Java (1.8)
• Apache Maven (3.3.9 or newer)
• Node.js (16.16.0 version – not working with 17+ !)
• Visual Studio Code IDE
Create SPA archetype project
1. Open cmd (run as administrator!!!)
2. Enter this command (in case of using AEM 6.5.5+, replace aemVersion="cloud" with
aemVersion="6.5.5", but you probably already have cloud version of AEM)
mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D
archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D
archetypeVersion=35 -D appTitle="WKND SPA React" -D appId="wknd-spa-react" -D
artifactId="aem-guides-wknd-spa.react" -D groupId="com.adobe.aem.guides.wkndspa.react" -D
frontendModule="react" -D aemVersion="cloud" -D includeDispatcherConfig="n"
Deploy and build the project
1. Ensure an instance of AEM is running locally on port 4502
2. From the command line navigate into the aem-guides-wknd-spa.react project directory.
3. Run the following command to build and deploy the entire project to AEM:
- the build will take a few minutes and should end with the following message:
npm start
.Header {
background-color: #FFEA00;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 99;
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.24);
}
.Header-container {
display: flex;
max-width: 1024px;
margin: 0 auto;
padding: 12px;
}
.Header-container h1 {
letter-spacing: 0;
font-size: 48px;
}
.page {
max-width: 1024px;
margin: 0 auto;
padding: 12px;
padding-top: 50px;
}
-if everything is fine, chages should be visible on page on localhost:3000 window immediately
- The changes made to the Header are currently only visible through the webpack-dev-server. Deploy
the updated SPA to AEM to see the changes
9. Deploy SPA updates to AEM – Back to the IDE, right click on base folder of the project
(aem-guides-wknd-spa.react) and choose Open in Integrated Terminal. Run the following
command:
mvn clean install -PautoInstallSinglePackage
IMPORTANT!!!
New changes would not transfer to the AEM automatically, you need to deploy it every time with
mvn clean install -PautoInstallSinglePackage command (see above).
Once you run webpack dev server with npm start command, you do not need to do it again until
server on localhost:3000 is down.
Server on localhost:3000 can be put down from the console (one where you started it with npm
start) with CTRL + C command. In case you closed that specific console, you can put it down by
running the following command in cmd: