Fixes #4020 - Move static handling to a filter

Needed for @static to work on other OSes