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

theme files not being exposed unless public folder is present #35

Open
dylangrech92 opened this issue Jul 13, 2020 · 4 comments
Open

theme files not being exposed unless public folder is present #35

dylangrech92 opened this issue Jul 13, 2020 · 4 comments

Comments

@dylangrech92
Copy link

So, due to some limitation in the hosting providers I wasn't able to create a public directory and instead used the native _resources directory in the root. After a bit of refactoring of my themes decided to use the expose feature for the static files but it simply wouldn't work. All the vendor modules where being exposed but anything in the themes directory would not.

After creating a public folder everything worked fine for the themes but it obviously broke all the paths to the vendor modules.

Is it possible to have themes expose to _resources directory like the vendor modules please?

@dylangrech92
Copy link
Author

dylangrech92 commented Jul 14, 2020

A much more annoying issue is happening now that I switched to using a public folder. From time to time vendor-expose completes deletes the contents of the source directory example: vendor/silverstripe/admin/client/dist/.

When it happens with module files it's not that big of a deal cause I can delete the whole module and re-install it with composer which fixes the problem until it decides to delete the files again.

Apache: Server version: Apache/2.4.6 (CentOS)
PHP: PHP 7.2.32
Vagrant: 2.2.7 with Virtualbox on Windows 10

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "minimal/centos7"
  config.vm.box_check_update = false
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.network "public_network"
  config.vm.synced_folder ".", "/var/www/modules",
	owner: "apache", group: "apache"
  config.vm.provider "virtualbox" do |vb|
      vb.gui = false
      vb.memory = "2048"
  end
end

@Cheddam
Copy link
Member

Cheddam commented Jul 21, 2020

Hey @dylangrech92, sorry to hear you're having issues. Can you confirm that you've applied the appropriate expose config to your composer.json file to ensure your theme files are picked up by vendor-plugin? For example:

    "extra": {
        "expose": [
            "themes/mytheme/css",
            "themes/mytheme/js",
        ]
    }

For the second issue, how are you running vendor-expose when this deletion occurs?

@dylangrech92
Copy link
Author

hey @Cheddam I have the theme as a stand alone repo with the following composer.json:

{
  "name": "themes/mytheme",
  "description": "mytheme",
  "type": "silverstripe-theme",
  "require": {
    "composer/installers": "*",
    "silverstripe/vendor-plugin": "^1.0",
    "silverstripe/framework": ">=4"
  },
  "extra": {
    "expose": [
      "css",
      "fonts",
      "images",
      "javascript"
    ]
  }
}

So to clarify, this works perfectly if a public folder exists, however if it doesn't, these wouldn't be exposed to _resources.

Using your recommendation worked but that would mean such config would need to exist in the app's composer.json making it "smelly".

As for the second issue I managed to debug enough to find out that it's a Vagrant problem... Vagrant, mounted folders and composer simply don't play well together so symlink behavior is unreliable at best. Forcing the copy method fixes that second problem. As a suggestion I would put something like a disclaimer in the README for anyone using Vagrant to default to copy instead of auto (I doubt there's any flag to detect it automatically)

Thanks :)

@Cheddam
Copy link
Member

Cheddam commented Jul 22, 2020

Thanks for the additional context @dylangrech92, glad to hear you sorted the second issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants