@nrwl/angular:library

Creates an Angular library.

Examples

Creates the my-ui-lib library with an ui tag:

nx g @nrwl/angular:library my-ui-lib --tags=ui

Usage

nx generate library ...
nx g lib ... #same

By default, Nx will search for library in the default collection provisioned in workspace.json.

You can specify the collection explicitly as follows:

nx g @nrwl/angular:library ...

Show what will be generated without writing to disk:

nx g library ... --dry-run

Options

addModuleSpec

boolean
Default: false

Add a module spec file.

addTailwind

boolean
Default: false

Whether to configure Tailwind CSS for the application. It can only be used with buildable and publishable libraries. Non-buildable libraries will use the application's Tailwind configuration.

buildable

boolean
Default: false

Generate a buildable library.

compilationMode

string
Accepted values: full, partial

Specifies the compilation mode to use. If not specified, it will default to partial for publishable libraries and to full for buildable libraries. The full value can not be used for publishable libraries.

changeDetection

c
string
Default: Default
Accepted values: Default, OnPush

The change detection strategy to use in the new component. Disclaimer: This option is only valid when --standalone is set to true.

directory

string

A directory where the library is placed.

displayBlock

b
boolean
Default: false

Specifies if the component generated style will contain :host { display: block; }. Disclaimer: This option is only valid when --standalone is set to true.

flat

boolean
Default: false

Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when --standalone is set to true.

importPath

string

The library name used to import it, like @myorg/my-awesome-lib. Must be a valid npm name.

inlineStyle

s
boolean
Default: false

Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file. Disclaimer: This option is only valid when --standalone is set to true.

inlineTemplate

t
boolean
Default: false

Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file. Disclaimer: This option is only valid when --standalone is set to true.

lazy

boolean
Default: false

Add RouterModule.forChild when set to true, and a simple array of routes when set to false.

linter

string
Default: eslint
Accepted values: eslint, none

The tool to use for running lint checks.

name

Required
string
Pattern: ^[a-zA-Z].*$

The name of the library.

publishable

boolean
Default: false

Generate a publishable library.

prefix

p
string
Format: html-selector

The prefix to apply to generated selectors.

parent

string

Path to the parent route configuration using loadChildren or children, depending on what lazy is set to.

routing

boolean
Default: false

Add router configuration. See lazy for more information.

skipFormat

boolean
Default: false

Skip formatting files.

simpleModuleName

boolean
Default: false

Keep the module name simple (when using --directory).

skipPackageJson

boolean
Default: false

Do not add dependencies to package.json.

skipTsConfig

boolean
Default: false

Do not update tsconfig.json for development experience.

strict

boolean
Default: true

Create a library with stricter type checking and build optimization options.

standaloneConfig

boolean

Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json.

setParserOptionsProject

boolean
Default: false

Whether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.

skipModule

boolean
Default: false

Whether to skip the creation of a default module when generating the library.

standalone

boolean
Default: false

Generate a library that uses a standalone component instead of a module as the entry point.

style

string
Default: css
Accepted values: css, scss, sass, less, none

The file extension or preprocessor to use for style files, or none to skip generating the style file. Disclaimer: This option is only valid when --standalone is set to true.

skipTests

boolean
Default: false

Do not create spec.ts test files for the new component. Disclaimer: This option is only valid when --standalone is set to true.

selector

string
Format: html-selector

The HTML selector to use for this component. Disclaimer: This option is only valid when --standalone is set to true.

skipSelector

boolean
Default: false

Specifies if the component should have a selector or not. Disclaimer: This option is only valid when --standalone is set to true.

tags

string

Add tags to the library (used for linting).

unitTestRunner

string
Default: jest
Accepted values: karma, jest, none

Test runner to use for unit tests.

viewEncapsulation

v
string
Accepted values: Emulated, None, ShadowDom

The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when --standalone is set to true.