Skip to content

Instantly share code, notes, and snippets.

@SteveALee
Last active September 16, 2021 05:12
Show Gist options
  • Save SteveALee/0e78dff6040780720093a14ce3a6f0ba to your computer and use it in GitHub Desktop.
Save SteveALee/0e78dff6040780720093a14ce3a6f0ba to your computer and use it in GitHub Desktop.
Have browsers update when editing 11ty config file

By default 11ty devmode uses browsersync to reload webbrowsers whenever it regenerates pages to _site. It does this automatically when template files change.

However, the .eleventy.js file is only loaded when 11ty starts so if you edit shortcodes (say) you need to stop and restart 11ty.

The solution is to use nodemon to restart 11ty automatically when the config file changes. But then you need to use browser F5 to refresh. The solution to that is to get browsersync to reload the browsers To achieve that, the 11ty browsersync config option allows you to define a callback when browsersync is ready and you can add a browser reload call there.

Here's example code from music-practice-tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment