Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths dependent on install (Drupal vs standalone) #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

evanmwillhite
Copy link

If you're running Pattern Lab inside of Drupal (e.g., DRUPAL/themes/contrib/emulsify/pattern-lab/public/), the paths determined by this extension are different. This tries to fix the broken ones in Drupal while keeping it working in standalone Emulsify installations

@evanmwillhite evanmwillhite added the enhancement New feature or request label Sep 6, 2018
@waako
Copy link

waako commented Feb 18, 2019

This does make paths work if accessing pattern-lab through:
site-name/themes/contrib/emulsify/pattern-lab/public
but then broken for localhost:3000/pattern-lab/public/

In the case of emulsify (or theme based on emulsify) I've found this relative path seems to work everywhere: ../../../../ regardless of the component depth it's attached to.

@hawkeyetwolf
Copy link

hawkeyetwolf commented Jul 10, 2019

This PR is a really clever and important fix! Is there a way to avoid hard-coding the components directory name? E.g., by searching for a file we can absolutely guarantee is present with all PatternLab installations, like the config.yml or PatternLab console CLI, then deducing the correct path from there?

In case it's helpful, we can determine the theme name from the string passed to attach_library() ('theme_name/library_name'). The most reliable way to then determine the theme directory would be via globbing for theme_name.libraries.yml and calling dirname() on the result.

The bigger issue I see is the assumption that the "themes" directory lives in the webroot. This will work for most Drupal 8 sites, except those who put their theme in a sites sub-directory. And almost all Drupal 7 sites would have their theme either in /sites/all or another sites sub-directory.

I'm not sure there's a good way to get around this issue. Relative paths assume a certain structure to the patterns directory. And I don't see a way to reliably build absolute paths given the "themes" directory structure variation I noted above. The only "bullet-proof" option I see is a "themePath" configuration setting, as proposed in #11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants