Is dist meant to be included in the trellis (example site) repo?

I’m unclear as to the typical and/or intended approach to deploying the compiled dist directory to remote servers with Trellis.

I see that the Roots-example-project doesn’t include it in the repo. I can upload it with

rsync -avP dist remote:path_to_current_Sage_dir

But I’m betting that’s not the recommended approach.

Can someone please school me?

Thanks.

Check deploy hooks in the docs and deploy-hooks/build-before.yml. You can setup that hook to either build the assets on your destination server or to simply copy the locally built files.

Thank you @cfx. I’m not totally clear on the process. Do I need to create and reference a new .yml file in order to say, configure Ansible to run the gulp tasks in the roles/deploy/hooks/build-after.yml tasks? Is there an example you might be able to point me to?

Yes sir, check the docs I linked to up there ^^

That specific file has examples and comments that should get you through it all. Also, these are Ansible playbooks for Trellis and they have little/nothing to do with Gulp unless you explicitly configure the sections in that file to run Gulp and build your Sage assets before copying them to the destination server as part of your deploy.

For best results, read all those docs, not just the specific section I linked to :wink:

1 Like

Oh look. trellis/deploy-hooks/build-before.yml contains the locally run version:

`# Placeholder `deploy_build_before` hook for building theme assets locally
# and then copying the files to the remote server
#
# Uncomment the lines below and replace `sage` with your theme folder
#
# ---
# - name: Run npm install
#   command: npm install
#   connection: local
#   args:
#     chdir: "{{ project.local_path }}/web/app/themes/sage"
#
# - name: Run bower install
#   command: bower install
#   connection: local
#   args:
#     chdir: "{{ project.local_path }}/web/app/themes/sage"
#
# - name: Run gulp
#   command: gulp --production
#   connection: local
#   args:
#     chdir: "{{ project.local_path }}/web/app/themes/sage"
#
# - name: Copy project local files
#   synchronize:
#     src: "{{ project.local_path }}/web/app/themes/sage/dist"
#     dest: "{{ deploy_helper.new_release_path }}/web/app/themes/sage"
#     group: no
#     owner: no
#     rsync_opts: --chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r

`

I guess the first option of running gulp on the server would be a matter of updating trellis/roles/deploy/hooks/build-after.yml with similar code, updating paths to something like {{ deploy_helper.new_release_path }}/web/app/themes/my_theme

Thank you very much.

Man it sure is easier than I deserve to create web apps. Seems like somebody has done just about everything for us already. : )