Creating a Theme
important
If this is your first experience developing Shopify themes, we recommend you to start by reading the basics of Shopify themes development at the Shopify's Themekit documentation.
#
Generating ThemesGenerating new themes can be done with the following:
This creates the following theme structure:
The main.ts content should look similar to this:
Note that the @my-org/my-theme
in the import paths are an alias to the apps/my-theme/src
path configured in your workspace root tsconfig.base.json
file.
#
Theme ConfigurationAfter generating your theme, the next step is to configure the themekit's apps/my-theme/config.yml
file.
tip
To know more about configuring the themekit's config.yml
file, see the Themekit Configuration Reference.
#
Theme CommandsWhen a Shopify theme is added to the workspace.json, the following targets are available for execution:
#
buildThe build command will compile the application using Webpack. It supports a production configuration by building with the following command:
Additional configurations can be added in the workspace.json. Changing the --configuration flag with the new configuration name will run that config.
For the specific configuration named production
, nx provides the following alias:
info
Learn more about the build command at the Build Executor doc.
#
serveBuilds and servers the theme using a local assets server and a runs a BrowserSync instance that proxies your theme preview.
The serve command will run in watch mode. This allows code to be changed, and the theme will be rebuilt automatically.
Different build configurations can be used when serving a theme, they can be configured in the target options inside the workspace.json
file or using cli options.
info
Learn more about the serve command at the Serve Executor doc.
#
deployDeploys the theme's last build to the themekit environment configured in the apps/<theme-name>/config.yml
file. It will use the development
environment by default.
info
Learn more about the deploy command at the Deploy Executor doc.