or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

commands.mdconfiguration.mdindex.mdprogrammatic-api.md

configuration.mddocs/

0

# Configuration

1

2

ng-packagr supports comprehensive configuration through JSON files and programmatic options, with JSON schema validation for both package and entry point configurations.

3

4

## Capabilities

5

6

### NgPackagr Options

7

8

Primary configuration options for controlling the build process.

9

10

```typescript { .api }

11

interface NgPackagrOptions {

12

/** Whether or not ng-packagr will watch for file changes and perform an incremental build */

13

watch?: boolean;

14

/** Enable/disable build caching (default: true except in CI environments) */

15

cacheEnabled?: boolean;

16

/** Custom cache directory path (default: auto-detected system cache) */

17

cacheDirectory?: string;

18

/** Enable and define the file watching poll time period in milliseconds */

19

poll?: number;

20

}

21

```

22

23

**Usage Examples:**

24

25

```typescript

26

import { ngPackagr } from "ng-packagr";

27

28

// Build with caching disabled

29

await ngPackagr()

30

.forProject('./ng-package.json')

31

.build({

32

cacheEnabled: false

33

});

34

35

// Watch mode with custom poll interval

36

await ngPackagr()

37

.forProject('./ng-package.json')

38

.build({

39

watch: true,

40

poll: 2000

41

});

42

```

43

44

### CLI Arguments

45

46

Configuration options when using ng-packagr from the command line.

47

48

```typescript { .api }

49

interface CliArguments {

50

/** Path to the project file 'package.json', 'ng-package.json', or 'ng-package.js' */

51

project: string;

52

/** Whether or not ng-packagr will watch for file changes and perform an incremental build */

53

watch?: boolean;

54

/** Path to a tsconfig file */

55

config?: string;

56

/** Enable and define the file watching poll time period in milliseconds */

57

poll?: number;

58

}

59

```

60

61

## Configuration Files

62

63

### ng-package.json

64

65

Main configuration file for Angular packages. Based on the NgPackageConfig schema.

66

67

**Example ng-package.json:**

68

69

```json

70

{

71

"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",

72

"dest": "dist/my-library",

73

"deleteDestPath": true,

74

"lib": {

75

"entryFile": "src/public_api.ts",

76

"cssUrl": "inline"

77

},

78

"assets": [

79

"src/assets/**/*"

80

],

81

"allowedNonPeerDependencies": [

82

"lodash",

83

"rxjs"

84

]

85

}

86

```

87

88

**Key Configuration Properties:**

89

90

- `dest` (string): Destination folder for distributable binaries (default: "dist")

91

- `deleteDestPath` (boolean): Delete output path before build (default: true)

92

- `lib.entryFile` (string): Entry file to the public API (default: "src/public_api.ts")

93

- `lib.cssUrl` (string): CSS URL handling - "none" or "inline" (default: "inline")

94

- `assets` (array): List of files to copy into the package

95

- `allowedNonPeerDependencies` (array): Dependencies allowed in dependencies/devDependencies

96

- `keepLifecycleScripts` (boolean): Keep 'scripts' section in package.json (default: false)

97

98

### ng-entrypoint.json

99

100

Configuration file for secondary entry points in Angular libraries.

101

102

**Example ng-entrypoint.json:**

103

104

```json

105

{

106

"$schema": "../../node_modules/ng-packagr/ng-entrypoint.schema.json",

107

"lib": {

108

"entryFile": "src/secondary/public_api.ts",

109

"flatModuleFile": "secondary-module",

110

"cssUrl": "inline"

111

}

112

}

113

```

114

115

### Configuration in package.json

116

117

ng-packagr configuration can be embedded directly in package.json:

118

119

```json

120

{

121

"name": "my-angular-library",

122

"ngPackage": {

123

"dest": "dist/my-library",

124

"lib": {

125

"entryFile": "src/public_api.ts"

126

}

127

}

128

}

129

```

130

131

## Advanced Configuration

132

133

### TypeScript Configuration

134

135

Custom TypeScript configuration can be provided:

136

137

```typescript

138

import { ngPackagr } from "ng-packagr";

139

140

// With custom tsconfig file

141

await ngPackagr()

142

.forProject('./ng-package.json')

143

.withTsConfig('./tsconfig.lib.json')

144

.build();

145

146

// With programmatic TypeScript config

147

await ngPackagr()

148

.forProject('./ng-package.json')

149

.withTsConfig({

150

compilerOptions: {

151

target: 'ES2022',

152

lib: ['ES2022', 'DOM']

153

}

154

})

155

.build();

156

```

157

158

### Caching Configuration

159

160

Build caching can be configured programmatically:

161

162

```typescript

163

import { ngPackagr } from "ng-packagr";

164

165

await ngPackagr()

166

.forProject('./ng-package.json')

167

.build({

168

cacheEnabled: true,

169

cacheDirectory: './custom-cache-dir'

170

});

171

```

172

173

The cache directory defaults to:

174

- System cache directory with `ng-packagr` subfolder, or

175

- `{tmpdir}/ng-packagr` if system cache is unavailable

176

177

Caching is automatically disabled in CI environments (when `CI=true` or `CI=1`).

178

179