File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,40 @@ More env flags that are usually passed by the CLI automatically:
45
45
- ` --env.platform=<platform> ` - for specifying the platform to use. Can be ` android ` or ` ios ` , or a custom platform in the future.
46
46
- ` --env.hmr ` - ` true ` if building with HMR enabled
47
47
48
+ #### Using flags at runtime
49
+
50
+ In your app logic you can access ` env ` variables like the following:
51
+
52
+ ``` js
53
+ if (process .env .production ) {
54
+ // this is a build executed with the `--env.production` flag
55
+ // typically this would be your release build
56
+ } else {
57
+ // this is a debug/dev build
58
+ }
59
+ ```
60
+
61
+ ::: tip Note
62
+ If you want to check if you are in Dev or Release mode you can also use:
63
+
64
+ ``` js
65
+ if (__DEV__ ) {
66
+ // this is dev builds
67
+ }
68
+ ```
69
+
70
+ :::
71
+
72
+ #### Using a .env file
73
+
74
+ You can add a ` .env ` file to your project root and add any values to it and access those at runtime.
75
+
76
+ ``` js
77
+ if (process .env .VAR_NAME ) {
78
+ // do work here if the variable is true
79
+ }
80
+ ```
81
+
48
82
### CLI flags
49
83
50
84
When running a NativeScript app the following flags have an effect on the webpack config:
You can’t perform that action at this time.
0 commit comments