Minimal CMS block

I try to create a custom CMS block to be dragged+dropped into a page.

It shows in the intended manner as a preview in the list of CMS blocks, one of the text blocks.

But when I try to drop it into a page, I get the error: Uncaught TypeError: Can’t convert undefined to object. The index.js in the CMS block map looks like this:

import ‚./component‘; import ‚./preview‘;Shopware.Service(‚cmsService‘).registerCmsBlock({ name: ‚trainings-list‘, label: ‚sw-cms.blocks.general.label‘, category:‚text‘, component: ‚sw-cms-block-text-trainings-list‘, previewComponent: ‚sw-cms-preview-text-trainings-list‘, defaultConfig: { } });

The index.js in the component map like so:

import template from ‚./sw-cms-block-text-trainings-list.html.twig‘; import ‚./sw-cms-block-text-trainings-list.scss‘;Shopware.Component.register(‚sw-cms-block-text-trainings-list‘, { template });

And the component twig.html is empty.

{% block sw_cms_block_text_trainings_list %} {% endblock %}

Apparently I have done something wrong, or didn’t use the proper syntax, maybe I have to add something but I can’t find the solution. What am I missing?

 

Do you also have a main.js file where you imported your module?