Include files in config.php

I have a large config.php file due to many routes, and I wanted to know if I can include external files to organize it better. I want to include route action functions specifically.

Yes, see https://github.com/getkirby/getkirby.com/blob/master/site/config/config.php#L21 and the included file: https://github.com/getkirby/getkirby.com/blob/master/site/config/routes.php

The second link’s implementation is close to what I need. Instead of going to a page, where can I specify a function to use in config?

For example:

'action' => myCustomFunction($argFromPattern)

I used a simple plugin and it works:

'action' => function($argFromPattern) {
  return myCustomFunction($argFromPattern);
},