larowlan / vite-plugin-twig-drupal

Provides a vite plugin for rendering Drupal flavoured twig files with Storybook
MIT License
15 stars 4 forks source link

Add support for Single Directory Components (SDC) #17

Closed estebanpcastro closed 3 months ago

estebanpcastro commented 3 months ago

When I use this kind of sintaxis to embed other twig file with SDC, I got an error

"Pre-transform error: Failed to resolve import" "Does the file exist? Plugin: vite:import-analysis"

Do you know if I need to add extra config, thanks in advance

larowlan commented 3 months ago

Can you share your twig file?

estebanpcastro commented 3 months ago

Sure here is

<div{{ attributes.addClass(classes) }}> {% block content %} {% embed 'web_foundation:button' with { button_html_tag: 'a', url: url, color: button_style, disabled: button_disabled, button_attributes: button_attributes } %} {{ link }} {{ icon_link|raw }} {% endembed %} {% endblock %}

As you can see, I'm trying to embed another component Button that already works, web_foundation is the custom theme and button component is part of the components folder

image

image
larowlan commented 3 months ago

What have you configured for namespaces in the twig options for your vite.config.js I've not seen that syntax before, I would have expect it would need @web_foundation/button/button.twig if you have mapped @web_foundation somewhere.

Are you using something custom in Drupal to support web_foundation:button?

estebanpcastro commented 3 months ago

I'm using SDC in Drupal is not custom implementation.

How I can map @web_foundation as the folder path to the custom theme?

Note: I base the integration with storybook using this post

larowlan commented 3 months ago

There's no SDC support in this project - I'll need to investigate that

github-actions[bot] commented 3 months ago

:tada: This issue has been resolved in version 1.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: