Skip to content

Commit f3cfdb8

Browse files
committed
Allow configuration of webpack rules
1 parent a4b43a5 commit f3cfdb8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/@angular/cli/lib/config/schema.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@
106106
"type": "boolean",
107107
"default": false
108108
},
109+
"loaderRules": {
110+
"description": "Array of matching rules extending the default webpack configuration.",
111+
"type": "array",
112+
"items": {
113+
"type": "object",
114+
"properties": {
115+
"test": {
116+
"type": "string"
117+
},
118+
"loader": {
119+
"type": "string"
120+
}
121+
},
122+
"required": ["test", "loader"],
123+
"additionalProperties": false
124+
}
125+
},
109126
"styles": {
110127
"description": "Global styles to be included in the build.",
111128
"type": "array",

packages/@angular/cli/models/webpack-configs/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
3030
const nodeModules = path.resolve(projectRoot, 'node_modules');
3131

3232
let extraPlugins: any[] = [];
33-
let extraRules: any[] = [];
33+
let extraRules: any[] = appConfig.loaderRules.map((entry: any) => {
34+
return { test: new RegExp(entry.test), loader: entry.loader };
35+
}) || [];
3436
let entryPoints: { [key: string]: string[] } = {};
3537

3638
// figure out which are the lazy loaded entry points

0 commit comments

Comments
 (0)