Support for Custom Resource Paths
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Yes
Tell us about the problem
We are not able to specify custom App_Resources and fonts paths when initializing the application, thus polluting our custom folder structure. This also causes plugin authors to follow this habit.
The proposed solution is providing a new parameter paths to application.start like so:
require("nativescript-i18n"); // preloaded plugin
var application = require("application");
application.paths.fonts = "resources/fonts";
application.paths.i18n = "resources/i18n"; // automatically set by preloaded plugin
application.start({ main: "..." }); // from this point on, paths are loaded
If paths or the a key isn't specified it will use the default, so it's non-breaking.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
App_Resources is actually compiled into the application as resources; when the app is installed on the device there is no "app_resources" folder in the final apk/ipa as everything inside is a compiled resource; so I'm not sure how this "pollutes" anything.
As for fonts, you can put fonts anywhere; however you have to manually register them then; only the "Fonts" folder auto-registers fonts...
@NathanaelA The concern isn't with the location after compiling, but while developing. A clean project structure is "polluted" with these folders under app.
I can't find instructions anywhere on registering fonts, but still, this location is something that should be changeable when initializing the application. There is no reason to hard-code these things.
I happen to prefer where it is at; it makes it very easy to re-hydrate an app stored in git, or to zip up everything you need to send to a client. When you start adding addition folders you have to track/zip it can easily complicate things. But I can understand your POV.
One thing you also need to consider; when you start "moving" things to be in a "variable" place; all this does complicate the tools for very little gain; and in fact it will greatly complicate tech support. Right now, I (or support) can ask people to check their /app/app_resource/android/andoidmanifest.xml and they will be able to follow that literal path the file. If you start moving things; then tech support become vastly more complicated as I have no idea where your primary AndroidManifest.xml file is actually stored (or other files that are fixed that can cause issues)... Same with font; with fonts, I can say, can you please double check "xyz" is in your "/app/fonts" folder. Moving it; just complicates tech support and tooling. So my personal opinion is that this just complicates things for no major gain. Having an opinionated framework sometimes is annoying; but on the flip side everything is in a fixed known location...
Now as to manually registering font, it is something you used to have to do early on in the frameworks life; if you check my blog (fluentreports.com/blog) for one of the earliest font posts; you will see how to do it.
@NathanaelA If you prefer that, that's your preference, and it is still the default. I am simply proposing that this preference isn't forced on the rest of us when we structure our projects.
Most people will use the defaults, so the scenario you mentioned is a non-issue. For those of us who don't, it allows us greater flexibility. Edit: Added an example to the 1st post.
@tsonevn any chance this will be in 2.5?
Project paths are configurable in nativescript.config.ts: appPath sets the app source folder and appResourcesPath the App_Resources location. Closing as completed — please open a new issue if you need another folder made configurable.