Building and Publishing an App
When you generate a new app using the yuuvis client CLI (version 19.7.0 or later), it automatically creates an npm script in your project’s package.json that allows you to build the app as a standalone Angular library. This is essential for publishing your app to an npm registry so other projects can install and use it.
Build Script Generation
Section titled “Build Script Generation”For an app named myapp, the CLI generates the following script:
{ ... "scripts": { ... "build:app:myapp": "ng build myapp" ... } ...}The script follows the naming convention build:app:{app-name} and uses Angular’s ng build command to compile the app library.
Building Your App
Section titled “Building Your App”To build your app library, run:
npm run build:app:myappThis command compiles your app using ng-packagr, which:
- Transpiles TypeScript to JavaScript
- Generates type definitions (
.d.tsfiles) - Creates optimized bundles for distribution
- Prepares the package for npm publication
The build output is placed in the dist/ directory:
dist/└── myapp/ ├── esm2022/ # ES2022 modules ├── fesm2022/ # Flattened ES2022 modules ├── lib/ # Compiled JavaScript and type definitions ├── package.json # Generated package metadata └── README.md # Package documentationPublishing to npm
Section titled “Publishing to npm”After building your app, you can publish it to an npm registry:
cd dist/myappnpm publishFor scoped packages (e.g., @mycompany/myapp), ensure your app is configured with the correct scope in its package.json. You may also want to publish to a private registry:
cd dist/myappnpm publish --registry https://registry.mycompany.comUsing the Published App
Section titled “Using the Published App”Once published, other projects can install your app using the add command:
yuv add app @mycompany/myapp