0
votes

I've created 2 files: "config.debug.ts" & "config.release.ts". My understanding is that NativeScript's build script should copy the appropriate file to "config.ts" during the build. And then I should be able to do something like "import { config } from './config'" from my other *.ts files. That however does not happen and I'm getting a compilation error when doing "tns run".

Now, I'm in doubt if I'm doing this properly at all.. What is the "true NS" way to have different configs for debug & release builds?

You can use nativescript-hook-debug-production plugin for defining different configuration for production and release. - Nikolay Tsonev
@NikolayTsonev did you try it? I did and it did not work. The compiler produces error at this line: "import { config } from './config'". Says file "config.ts" is not found. I also can see that file is not created on the disk. - Dmytro Gokun
If you are facing an issue with the plugin you can contact the author by opening a new issue here - github.com/markosko/nativescript-hook-debug-production/issues. In the meantime, you can also check the link here - github.com/NativeScript/NativeScript/issues/…, where it is shown how to set up config base on the mode(debug , release) - Nikolay Tsonev