I have a very similar issue to Excluding a directory from Jekyll watch, but I thought it was different enough to warrant it's own question.
_config.yml:
exclude: [
"my_ignored_directory"
]
Using jekyll build --watch
, the folder my_ignored_directory
will be successfully ignored from the watch task, but it will also not be built.
Is there are way to exclude a folder of my choosing from the --watch
task, but not to be excluded from being built?
(Note: there is no error in the console)
The answer is no, because excluded files for watch are : _config.*
, destination folder
(usually _site
) and content of config['exclude']
.
See jekyll-watch code
Edit : But ...
We can override Jekyll::Watcher::custom_excludes
methods with a plugin.
_plugins/jekyll-watcher-override.rb
require 'jekyll-watch'
module Jekyll
module Watcher
# replace old method by new method
# new method is now :custom_excludes
# overridden method is now :old_custom_excludes
alias_method :old_custom_excludes, :custom_excludes
def custom_excludes(options)
# if we have an "exclude_from_watch" variable in configuration
if options['exclude_from_watch'] then
# merge exclude and exclude_from_watch
(options['exclude'] << options['exclude_from_watch']).flatten!
end
# pass the new option array to overridden method
old_custom_excludes(options)
end
end
end
In _config.yml, just set an exclude_from_watch
variable :
exclude_from_watch:
- css
Now, when you do a jekyll serve
any file / folder in exclude_from_watch
will be ignored if they change.