• Trellis

Remove Theme Source Files on Deploy

Avoid exposing your theme source files on the web by removing them during your Trellis deployments.

In most scenarios, you probably don’t want someone digging into the .scss and .js files you used to build your theme. We can tell Trellis to remove the source folder for your asset builds by using the hooks in Trellis deploys.

Create a new file in trellis/deploy-hooks/build-after.yml:

- name: Remove theme source files
  file:
    state: absent
    path: "{{ deploy_helper.new_release_path }}/web/app/themes/[theme name]/resources/assets"

Add to trellis/group_vars/all/main.yml:

deploy_build_after:
  - "{{ playbook_dir }}/roles/deploy/hooks/build-after.yml"
  - "{{ playbook_dir }}/deploy-hooks/build-after.yml"

Start the discussion on Roots Discourse

Join over 5,600 subscribers on our newsletter to get the latest Roots updates, along with occasional tips on building better WordPress sites.

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

“Easily the best WordPress email I get.” Colin OBrien

Ready to checkout?