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:
- Workspace root is identified
tsconfig.base.jsonpath mappings are parsed- Project dependencies are resolved
- 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-appProject 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 prodThis 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
-
tsconfig.base.json Paths
- Path aliases like
@myorg/shared-utils - Maps to actual lib directories
- Path aliases like
-
Nx Dependency Graph
- Direct and transitive dependencies
- Uses
npx nx graphfor accurate resolution
-
Webpack Aliases
- Custom aliases in
webpack.config.js - SCSS and asset imports
- Custom aliases in
-
Implicit Dependencies
- From
project.jsonimplicitDependencies
- From
-
Local File Dependencies
file:protocol in package.json
Bundled Content
For cloud builds, Norrix bundles:
| Content | Examples |
|---|---|
| App project | apps/my-mobile-app/ |
| Library dependencies | libs/shared/utils/, libs/ui/ |
| Root configs | nx.json, tsconfig.base.json, package.json |
| Tools | tools/ directory |
| Assets | libs/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-appProject-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 prodConfiguration 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
- Ensure you’re in the workspace root
- Check that the project has
nativescript.config.ts - Verify
project.jsonexists with correct name
Dependencies Missing
-
Run with verbose mode:
norrix build ios release --project myapp --verbose -
Check
tsconfig.base.jsonpaths -
Ensure libs are in the Nx dependency graph
-
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"]
}
}
}