Skip to main content
CESDK/CE.SDK/Web Editor/Guides

Configure the SDK to Use Assets Served From Your Own Servers

Learn how to serve assets from your own servers in the CreativeEditor SDK.

In this example, we explain how to configure the Creative Engine to use assets hosted on your own servers. While we serve all assets from our own CDN by default, it is highly recommended to serve the assets from your own servers in a production environment.

Prerequisites#

1. Add the CreativeEditorSDK to Your Project#

npm install --save @cesdk/engine@1.39.0

2. Decide what Assets you need#

We offer two sets of assets:

  • Core Assets - Files required for the engine to function.
  • Default Assets - Demo assets to quickstart your development.

⚠️ Warning#


Prior to v1.10.0, the CreativeEditorSDK and CreativeEditorSDK would load referenced default assets from the assets/extensions/* directories and hardcode them as /extensions/… references in serialized scenes.


To maintain compatibility for such scenes, make sure you're still serving the /extensions directory (included in version v1.9.2) from your baseURL. You can download them from our CDN.

3. Register IMG.LY's default assets#

If you want to use our default asset sources in your integration, call CreativeEditorSDK.addDefaultAssetSources({ baseURL?: string, excludeAssetSourceIds?: string[] } during initialization:

CreativeEditorSDK.create(config).then(async (instance) => {
await instance.addDefaultAssetSources();
await instance.createDesignScene();
});

This call adds IMG.LY's default asset sources for images, stickers, vectorpaths and filters to your engine instance. By default, these include the following source ids:

  • 'ly.img.image' - Sample images
  • 'ly.img.sticker' - Various stickers
  • 'ly.img.vectorpath' - Shapes and arrows
  • 'ly.img.filter.lut' - LUT effects of various kinds.
  • 'ly.img.filter.duotone' - Color effects of various kinds.

If you don't specify a baseURL option, the assets are parsed and served from the IMG.LY CDN. It's it is highly recommended to serve the assets from your own servers in a production environment, if you decide to use them. To do so, follow the steps below and pass a baseURL option to addDefaultAssetSources. If you only need a subset of the IDs above, use the excludeAssetSourceIds option to pass a list of ignored Ids.

4. Copy Assets#

Copy the CreativeEditorSDK core, etc. asset folders to your application's asset folder. The name of the folder depends on your setup and the used bundler, but it's typically a folder called assets or public in the project root.

cp -r ./node_modules/@cesdk/cesdk-js/assets public/

Furthermore, if you are using our IMG.LY default assets, download them from our CDN and extract them to your public directory as well.

If you deploy the site that embeds the CreativeEditorSDK together with all its assets and static files, this might be all you need to do for this step.

In different setups, you might need to upload this folder to your CDN.

5. Configure the CreativeEditorSDK to use your self-hosted assets#

Next, we need to configure the SDK to use our local assets instead of the ones served via our CDN. There are two configuration options that are relevant for this:

  • baseURL should ideally point to the assets folder that was copied in the previous step.

    This can be either an absolute URL, or a path. A path will be resolved using the window.location.href of the page where the CreativeEditorSDK is embedded. By default baseURL is set to our CDN.

  • core.baseURL must point to the folder containing the core sources and data file for the CreativeEditorSDK. Defaults to ${baseURL}/core

    This can be either an absolute URL, or a relative path. A relative path will be resolved using the the previous baseURL. By default, core.baseURL is set to core/.

    Normally you would simply serve the assets directory from the previous step. That directory already contains the core folder, and this setting does not need to be changed. For highly customized setups that separate hosting of the WASM files from the hosting of other assets that are used inside scenes, you can set this to a different URL.

  • CreativeEditorSDK.addDefaultAssetSources offers a baseURL option, that needs to be set to an absolute URL or a URL relative to the global baseURL option described above.

    This can be either an absolute URL, or a relative path. A relative path will be resolved using the the previous baseURL. By default, default sources parse and reference assets from https://cdn.img.ly/assets/v3.

const config = {
...
// Specify baseURL for all relative URLs.
baseURL: '/assets' // or 'https://cdn.mydomain.com/assets'
core: {
// Specify location of core assets, required by the engine.
baseURL: 'core/'
},
...
};
// Setup SDK and add default sources served from your own server.
CreativeEditorSDK.create(config).then(async (instance) => {
await instance.addDefaultAssetSources({ baseURL: 'https://cdn.mydomain.com/assets'})
await instance.createDesignScene()
})

Versioning of the WASM assets#

The .wasm and .data files that the CreativeEditorSDK loads from core.baseURL are changing between different versions of the CreativeEditorSDK. You need to ensure that after a version update, you update your copy of the assets.

The filenames of these assets will also change between updates. This makes it safe to store different versions of these files in the same folder during migrations, as the CreativeEditorSDK will always locate the correct files using the unique filenames.

It also means that if you forget to copy the new assets, the CreativeEditorSDK will fail to load them during initialization and abort with an Error message on the console. Depending on your setup this might only happen in your production or staging environments, but not during development where the assets might be served from a local server. Thus we recommend to ensure that copying of the assets is taken care of by your automated deployments and not performed manually.