Sail Knowledgebase

How to Use the .deployignore File with Sail CLI

This short guide will show you how to use the .deployignore file in your Sail projects to prevent certain files from being deployed to production.

If you like Sail, consider sponsoring us via GitHub!

What is .deployignore

The .deployignore file is an optional file that lists filenames and patterns that should be ignored during a sail deploy.

This is useful if you're using additional tools in your development environment, which for example rely on things like node_modules for building/testing/etc., or produce .log files and other temporary files which are not essential for your application to function in production.

These can be added to a file called .deployignore in the root directory of your Sail project.

The .deployignore file syntax

One entry per line, comments start with a #, simple patterns are supported, negate with !. Below are a few examples:

Ignore files named debug.log, in any directory or subdirectory:

debug.log

Ignore all .log files anywhere in your project:

*.log

Ignore all log files, except ones called important.log:

*.log
!important.log

Ignore an entire directory (even if it's in a subdirectory itself):

node_modules/

Ignore the readme.html file but only in the root project directory:

/readme.html

So this will still deploy wp-content/plugins/foo/readme.html for example.

Notes

Ignored files and directories will not appear in sail diff or sail deploy --dry-run, so they will likely not trigger pre-deploy hooks as well.

Dot-files (filenames and directories that begin with a ., such as .sail or .backups) are ignored regardless of what's in your .deployignore, so naturally, the .deployignore file itself will also not be shipped to production.

If you have any questions or feedback about deploying with Sail CLI, check out the getting help section.