Include Sage theme in Bedrock composer

Hello, I’m currently using Trellis + Bedrock. I plan to add a Sage theme but through composer.

I have successfully included my Sage theme repository into the Bedrock composer.

Deploying to the server also seems to be working. I can see and activate my Sage theme there.

However, the CSS and JS are missing! Oh, I just realized that the assets need to be compiled locally.

Then I uncomment the command in deploy-hooks/build-before.yml

When re-deployed, there was an error as follows:

Unable to change directory before execution: [Errno 2] No such file or
directory:

'/srv/www/###/releases/###/web/app/themes/mysage'

I’m assuming the folder isn’t ready yet. So what are the proper steps for using a Sage theme via composer?

1 Like

Can you show us your deploy-hooks/build-before.yml?

Besides, please double check your sage theme is checked under git under web/app/themes/mysage

I just uncomment the original code from trellis, then change sage to mysage

# Placeholder `deploy_build_before` hook for building theme assets on the
# host machine and then copying the files to the remote server
#
# ⚠️ This example assumes your theme is using Sage 9
# An example for themes built with Sage 8 can be found at: https://git.io/vdgUt
#
# Uncomment the lines below and replace `sage` with your theme folder
#
# ---
- name: Install npm dependencies
  command: yarn
  delegate_to: localhost
  args:
    chdir: "{{ project_local_path }}/web/app/themes/mysage"

- name: Install Composer dependencies
  command: composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts --classmap-authoritative
  args:
    chdir: "{{ deploy_helper.new_release_path }}/web/app/themes/mysage"

- name: Compile assets for production
  command: yarn build:production
  delegate_to: localhost
  args:
    chdir: "{{ project_local_path }}/web/app/themes/mysage"

- name: Copy production assets
  synchronize:
    src: "{{ project_local_path }}/web/app/themes/mysage/dist"
    dest: "{{ deploy_helper.new_release_path }}/web/app/themes/mysage"
    group: no
    owner: no
    rsync_opts: --chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r

Check the wordpress_sites.yml files and dubble check the local_path value.
It has to point to your Bedrock site directory.

@ngkusnd would you mind to show how you included your Sage theme repository into the Bedrock composer? I would like to do the same.