This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.
Deploying to Surge
This deployment example refers to Surge.
Prerequisites
Before you get started, you need to have:
- A Surge account, using the
surge
CLI. - A commercetools account and a Project.
- A Custom Application configured in the Merchant Center.
Configuration
In your Custom Application config, provide the Custom Application ID you got when you configured the Custom Application in the Merchant Center.
Moreover, you need to provide the production URL from your Surge project. You can keep the standard Surge URL https://<project>.surge.sh
or provide your custom domain.
{"env": {"production": {"applicationId": "ckvtahxl90097sys6har1e6n3","url": "https://<project>.surge.sh"}}}
Using environment variables
In case you want to avoid hardcoding certain values, for example the Application ID, or the Project key, you can use variable placeholders in your Custom Application config.
{"env": {"production": {"applicationId": "${env:APPLICATION_ID}","url": "https://<project>.surge.sh"}}}
Production bundles
The main command to create the production bundles is mc-scripts build
. The output folder is public
, which is what is going to be uploaded to Surge.
See Going to production for more information.
To properly support client-side routing, you need to rename the index.html
file to 200.html
before uploading the static files.
Deploying to Surge
Use the Surge CLI to upload the static files.
surge public https://<project>.surge.sh
That's it!
Test your deployment
In the Merchant Center you can now follow the steps to install the Custom Application and access it in your Projects.
The Custom Application won't render if you try to access it directly via the deployment URL, as it needs to be served within the Merchant Center Proxy Router.
Therefore, Preview deployments are not really useful. If you are interested in this functionality, let us know and open a support issue.