Flags & their usage
CLI flags
When running a NativeScript app, the following flags have an effect on the webpack config:
-
--no-hmr- disable HMR (enabled by default)
--env flags
The following --env flags can be passed to the cli when running or building:
-
--env.verbose— prints verbose logs and the internal config before building -
--env.replace=from:to— add file replacement rules. For source files (.jsand.ts) this will add a new alias to the config, for everything else, this will add a new copy rule. Example:--env.replace=./src/environments/environment.ts:./src/environments/environment.prod.tswould add an alias so when youimport { environment } from './environments/environment.ts'it will resolve & import from./environments/environment.prod.ts. -
--env.appComponents— allows passing additional App Components for android. For example, if you have a custom activity inmyCustomActivity.tsyou can pass--env.appComponents=myCustomActivity.ts. -
--env.production— enable a production mode (will minify the code) -
--env.report— generate a report with the BundleAnalyzerPlugin -
--env.profile— generate awebpack.stats.jsonto analyze on https://webpack.github.io/analyse/ -
--env.watchNodeModules— enable watchingnode_modulesfor changes. Useful when debugging plugins and making changes directly innode_modules. -
--env.e2e— enables E2E (end-to-end) mode — this currently enables thetestIDproperty in@nativescript/core
More env flags that are usually passed by the CLI automatically:
-
--env.appPath— path to the app source (same asappPathin thenativescript.config.ts) -
--env.appResourcesPath— path to App_Resources (same asappResourcesPathin thenativescript.config.ts) -
--env.nativescriptLibPath— path to the currently running CLI’s library. -
--env.android—trueif running on android -
--env.ios—trueif running on ios -
--env.platform=<platform>— for specifying the platform to use. Can beandroidorios, or a custom platform in the future. -
--env.hmr—trueif building with HMR enabled