Skip to Content
Platform GuidesNx Workspace Integration

Nx Workspace Integration

Norrix provides first-class support for Nx monorepos, automatically detecting workspace structure and dependencies.

Automatic Detection

Norrix detects Nx workspaces by looking for nx.json in parent directories. When detected:

  1. Workspace root is identified
  2. tsconfig.base.json path mappings are parsed
  3. Project dependencies are resolved
  4. All necessary libs are bundled for cloud builds

Building from Workspace Root

When running from the workspace root, use --project to specify the app:

cd my-nx-workspace norrix build ios release --project my-mobile-app

Project Discovery

If you omit --project, Norrix scans for NativeScript apps and prompts:

norrix build ios release # ? Select a NativeScript project: # › my-mobile-app (apps/my-mobile-app) # other-app (apps/other-app)

Build Configurations

Pass configurations with --config:

norrix build ios release --project my-app --config prod

This corresponds to configurations in project.json:

{ "targets": { "build": { "configurations": { "prod": { /* production settings */ }, "stg": { /* staging settings */ }, "dev": { /* development settings */ } } } } }

Dependency Resolution

Norrix automatically includes workspace dependencies in cloud builds:

What’s Detected

  1. tsconfig.base.json Paths

    • Path aliases like @myorg/shared-utils
    • Maps to actual lib directories
  2. Nx Dependency Graph

    • Direct and transitive dependencies
    • Uses npx nx graph for accurate resolution
  3. Webpack Aliases

    • Custom aliases in webpack.config.js
    • SCSS and asset imports
  4. Implicit Dependencies

    • From project.json implicitDependencies
  5. Local File Dependencies

    • file: protocol in package.json

Bundled Content

For cloud builds, Norrix bundles:

ContentExamples
App projectapps/my-mobile-app/
Library dependencieslibs/shared/utils/, libs/ui/
Root configsnx.json, tsconfig.base.json, package.json
Toolstools/ directory
Assetslibs/assets/

Environment Variables

Scope environment variables to specific projects:

# Set for specific project norrix env set API_KEY value --project my-mobile-app # List for specific project norrix env list --project my-mobile-app

Project-scoped variables are only injected when building that project.


Updates from Workspace

OTA updates also support workspace projects:

norrix update ios 1.0.1 --project my-mobile-app --config prod

Configuration Example

In an Nx workspace, your norrix.config.ts can be at the app level:

my-nx-workspace/ ├── nx.json ├── tsconfig.base.json ├── apps/ │ └── my-mobile-app/ │ ├── norrix.config.ts # App-specific config │ ├── nativescript.config.ts │ └── src/ └── libs/ ├── shared/ └── ui/
// apps/my-mobile-app/norrix.config.ts import { defineConfig } from '@norrix/cli'; export default defineConfig({ ios: { teamId: 'ABC123XYZ0', distributionType: 'enterprise', }, env: { variables: ['API_KEY'], files: ['.env.production'], }, });

Workspace Context

The CLI tracks workspace context in build records:

{ "workspaceType": "nx", "workspaceAppPath": "apps/my-mobile-app", "projectName": "my-mobile-app" }

This helps with:

  • Artifact organization
  • Env variable scoping
  • Build reproducibility

Troubleshooting

Project Not Found

  1. Ensure you’re in the workspace root
  2. Check that the project has nativescript.config.ts
  3. Verify project.json exists with correct name

Dependencies Missing

  1. Run with verbose mode:

    norrix build ios release --project myapp --verbose
  2. Check tsconfig.base.json paths

  3. Ensure libs are in the Nx dependency graph

  4. Verify webpack aliases are correct

Path Alias Issues

Ensure tsconfig.base.json paths are correct:

{ "compilerOptions": { "paths": { "@myorg/shared-utils": ["libs/shared/utils/src/index.ts"], "@myorg/ui": ["libs/ui/src/index.ts"] } } }