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 (.js
and.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.ts
would 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.ts
you 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.json
to analyze on https://webpack.github.io/analyse/ -
--env.watchNodeModules
— enable watchingnode_modules
for changes. Useful when debugging plugins and making changes directly innode_modules
. -
--env.e2e
— enables E2E (end-to-end) mode — this currently enables thetestID
property in@nativescript/core
More env flags that are usually passed by the CLI automatically:
-
--env.appPath
— path to the app source (same asappPath
in thenativescript.config.ts
) -
--env.appResourcesPath
— path to App_Resources (same asappResourcesPath
in thenativescript.config.ts
) -
--env.nativescriptLibPath
— path to the currently running CLI’s library. -
--env.android
—true
if running on android -
--env.ios
—true
if running on ios -
--env.platform=<platform>
— for specifying the platform to use. Can beandroid
orios
, or a custom platform in the future. -
--env.hmr
—true
if building with HMR enabled