Mojolicious applications work nicely from a working directory, but once the app is bundled for installation some of the configuration gets a little bit tricky. Though some examples are shown in the Mojolicious documentation, the process is still rather involved. However, Mojolicious::Plugin::InstallablePaths handles all the configuration for you (provided you follow a proscribed directory tree)!

As you can see, all non-module content is placed inside a directory named files directly inside the folder named for the module. In the above example this is the lib/MyApp/files/ directory. If the app had been Some::App then the directory would be lib/Some/App/files/.

There is no allowance for different names of these folders nor of different locations for them relative to the main module. Patches will be considered, but the primary purpose of this module is the simple generic case; to do strange things the Mojolicious path manipulation system should be used directly.

Before this call, the directories are not set correctly, so be sure to use it early! The plugin will detect if the directory tree exists as above (i.e. before installation) and use it directly or else it will attempt to use the File::ShareDir system to locate the directories (i.e. after installation). In this way, your app should always find its needed files, no matter what phase of development or installation!

Later, this directory can be found using the usual mechanisms that that File::ShareDir provides. Keep in mind that you should add it to the configure_requires key as you should for any module used in a Build.PL file.

Finally note that if passing clean_install => 1 at import, Module::Build::CleanInstall will be inserted into the inheritance tree at import time. This module ensures that old files are removed before upgrading an already installed module. The author recommends this option be enabled.