Does the Sage 9 working directory need to be located in wp-content/themes/?

This is maybe a weird, noobish question, but does the Sage 9 working directory need to be located inside the wp-content/theme/theme folder?

In our workflow it might make more sense to have Sage 9 at our project root folder, and have it output the compiled theme to /wp-content/theme/themename/. It would save a lot of typing of paths and make the repo that much cleaner. Something like:

projects/
  project1/
  project2/
    project2-theme # <- sage9 working directory
    www/
      [wordpress core]
      wp-content/themes/project2-theme # <- sage9 yarn output directory

We’re looking at moving to a docker-based dev workflow and something like this would help keep our git repo flat and our path typing short.

  1. All of our coding and yarn and composer commands would happen in /project2-theme/,

  2. While yarn run start and yarn run build:production would both compile to www/wp-content/themes/project2-theme/.

Sage contains more than just CSS and JS so it’s required to be in wp-content/themes

You could also symlink build files from the theme to another directory if you want to run them closer to the root. Might have to tweak other things in the build to account for that.

This isn’t supported or recommended :slight_smile:

I don’t think you can git commit the symlinks, though, can you? I thought they resolved to the full path.

It doesn’t have to be there for yarn run build:production, though. I run that command during my deploy process which checks out my repo but doesn’t even install WordPress at all. It then rsyncs the compiled theme to the wp-content/themes/on the production server. But yes the rsync copies more than just the compiled files — it copies app, dist, resources, vendor, and a few files.

I wonder if I can do the reverse of benword’s suggestion? On my local dev, symlink from inside wp-content/themes/ to my working directory outside the WordPress install.

Otherwise I think the better solution would be to run WordPress in the container and user docker volume to mount the local theme folder as the WordPress theme folder. This gives a flatter working directory and git repo, but Lando doesn’t do that by default.

At times on some personal projects I’ve had to use symlinks and can say it’s not the easiest setup but it can work. I’m not too sure but Git may have some “follow symlink” options.