or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

code-transformations.mdindex.mdplugin-configuration.mdresource-management.mdtypescript-compilation.mdwebpack-loader.md

plugin-configuration.mddocs/

0

# Plugin Configuration

1

2

Core webpack plugin for Angular AOT/JIT compilation with comprehensive configuration options for TypeScript integration and Angular-specific build requirements.

3

4

## Capabilities

5

6

### AngularWebpackPlugin

7

8

Main webpack plugin class that integrates Angular compilation into the webpack build process.

9

10

```typescript { .api }

11

/**

12

* Angular webpack plugin for AOT/JIT compilation

13

* Integrates Angular compiler with webpack build process

14

*/

15

class AngularWebpackPlugin {

16

constructor(options: AngularWebpackPluginOptions);

17

apply(compiler: Compiler): void;

18

}

19

```

20

21

**Usage Example:**

22

23

```typescript

24

import { AngularWebpackPlugin } from '@ngtools/webpack';

25

26

const plugin = new AngularWebpackPlugin({

27

tsconfig: './tsconfig.json',

28

jitMode: false,

29

directTemplateLoading: true,

30

fileReplacements: {

31

'./src/environments/environment.ts': './src/environments/environment.prod.ts'

32

},

33

substitutions: {

34

'process.env.NODE_ENV': '"production"'

35

}

36

});

37

```

38

39

### AngularWebpackPluginOptions

40

41

Configuration interface for the AngularWebpackPlugin with comprehensive options for TypeScript and Angular compilation settings.

42

43

```typescript { .api }

44

/**

45

* Configuration options for AngularWebpackPlugin

46

* Controls Angular compilation behavior and TypeScript integration

47

*/

48

interface AngularWebpackPluginOptions {

49

/** Path to the application's TypeScript configuration file */

50

tsconfig: string;

51

/** Overrides options in the TypeScript configuration file */

52

compilerOptions?: CompilerOptions;

53

/** Allows replacing TypeScript files with other TypeScript files in the build */

54

fileReplacements: Record<string, string>;

55

/** String substitutions to apply during compilation */

56

substitutions: Record<string, string>;

57

/** Causes plugin to load component templates directly from filesystem */

58

directTemplateLoading: boolean;

59

/** Enables emission of class metadata for Angular components */

60

emitClassMetadata: boolean;

61

/** Enables emission of NgModule scope information */

62

emitNgModuleScope: boolean;

63

/** Enables emission of class debug information */

64

emitSetClassDebugInfo?: boolean;

65

/** Enables JIT compilation mode instead of AOT */

66

jitMode: boolean;

67

/** File extension for processing inline component styles */

68

inlineStyleFileExtension?: string;

69

}

70

```

71

72

### Configuration Options Details

73

74

#### tsconfig

75

- **Type**: `string`

76

- **Default**: `"tsconfig.json"`

77

- **Description**: Path to the application's TypeScript configuration file. Relative paths are resolved from the webpack compilation context.

78

79

#### compilerOptions

80

- **Type**: `CompilerOptions` (optional)

81

- **Default**: `undefined`

82

- **Description**: Overrides options in the application's TypeScript configuration file. These options take precedence over those in tsconfig.json.

83

84

#### fileReplacements

85

- **Type**: `Record<string, string>`

86

- **Default**: `{}`

87

- **Description**: Allows replacing TypeScript files with other TypeScript files in the build. Useful for environment-specific configurations.

88

89

**Example:**

90

```typescript

91

fileReplacements: {

92

'./src/environments/environment.ts': './src/environments/environment.prod.ts',

93

'./src/config/dev.ts': './src/config/prod.ts'

94

}

95

```

96

97

#### substitutions

98

- **Type**: `Record<string, string>`

99

- **Default**: `{}`

100

- **Description**: String substitutions to apply during compilation. Useful for build-time constants.

101

102

**Example:**

103

```typescript

104

substitutions: {

105

'process.env.NODE_ENV': '"production"',

106

'BUILD_VERSION': '"1.2.3"'

107

}

108

```

109

110

#### directTemplateLoading

111

- **Type**: `boolean`

112

- **Default**: `true`

113

- **Description**: When enabled, the plugin loads component templates (HTML) directly from the filesystem. More efficient when only using raw-loader for templates.

114

115

#### emitClassMetadata

116

- **Type**: `boolean`

117

- **Default**: Varies based on build mode

118

- **Description**: Controls whether class metadata is emitted for Angular components and services.

119

120

#### emitNgModuleScope

121

- **Type**: `boolean`

122

- **Default**: Varies based on build mode

123

- **Description**: Controls whether NgModule scope information is emitted.

124

125

#### emitSetClassDebugInfo

126

- **Type**: `boolean` (optional)

127

- **Default**: `undefined`

128

- **Description**: Controls whether class debug information is emitted for debugging purposes.

129

130

#### jitMode

131

- **Type**: `boolean`

132

- **Default**: `false`

133

- **Description**: Enables JIT (Just-in-Time) compilation mode. When enabled, templates and styles are processed for runtime compilation rather than AOT.

134

135

#### inlineStyleFileExtension

136

- **Type**: `string` (optional)

137

- **Default**: `undefined`

138

- **Description**: When set, inline component styles will be processed by webpack as files with the provided extension.

139

140

**Example:**

141

```typescript

142

inlineStyleFileExtension: 'scss'

143

```

144

145

### Image Domains Collection

146

147

Global collection of image domains discovered during Angular application compilation.

148

149

```typescript { .api }

150

/**

151

* Set of image domains discovered during compilation

152

* Populated automatically by Angular compilation process

153

*/

154

const imageDomains: Set<string>;

155

```

156

157

**Usage Example:**

158

159

```typescript

160

import { imageDomains } from '@ngtools/webpack';

161

162

// After compilation, check discovered domains

163

console.log('Discovered image domains:', Array.from(imageDomains));

164

```

165

166

### Plugin Symbol

167

168

Unique symbol used for plugin identification and communication between plugin and loader.

169

170

```typescript { .api }

171

/**

172

* Unique symbol for Angular webpack plugin identification

173

* Used for internal communication between plugin and loader

174

*/

175

const AngularPluginSymbol: unique symbol;

176

```