Skip to main content

Automating tasks using SXA CLI

Abstract

Learn more about common SXA CLI tasks.

SXA CLI is a useful command line tool that helps you automate tasks for an SXA project. This topic describes the most common tasks. For a complete list of all tasks and possible additions, go to The SXA watch, build, and upload tasks.

If you have all the prerequisites in place, you can add a new theme for your SXA project using the following task:

sxa new <Theme name>

This task runs the create theme pipeline and after you answer a list of questions it stores the theme both locally and in Sitecore.

SXA-CLI-New_theme.png

All assets are stored locally. You can use GitHub or any other version control system to work together on styles and scripts.

SXA-CLI-Theme_folder.png

In Sitecore, there is a placeholder for the theme. By default, this folder does not contain any assets:

SXA-CLI-theme_in_sc.png

You can reconfigure theme settings at any time. For example, if you first chose not to upload CSS source files but later want to change this, you can (re)configure theme settings using the following task:

sxa config

If you finish developing and want to upload the changes, you can upload modified files automatically using the following task:

sxa watch All

For example, if you changed the sass styling of the accordion:

SXA-CLI-watch.png

If you want to build all Sass tasks and the minification. The following task updates all files locally but does not upload to the server.

sxa build

You can update and upload assets to your theme at any time, for example, if you work in a team and you want to update your local theme with the latest changes made by your colleagues. You can update your theme using the following task:

sxa rebuild All

This tasks uploads all scripts, images, and styles to the theme in Sitecore.

You can upload assets to your theme at any time. For example, if you made some changes in CSS and you want to upload these files only.

sxa upload Css