Skip to content

Commit 68908e0

Browse files
committed
docs(examples/angular): Fix CSP issues with inline event handler scripts
1 parent 01e47f6 commit 68908e0

File tree

7 files changed

+37
-5
lines changed

7 files changed

+37
-5
lines changed

examples/angular/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ This is a small Angular example app, which includes a `spa_config.js` to configu
99
3. Declare `spaConfig` in the `window` object via the TypeScript definition file `/src/@types/spa_config.d.ts`
1010
4. Add `<script src="./spa_config.js"></script>` to `index.html`
1111
5. Add a `/config/default.yaml` configuration file to the image, which allows 'unsafe-inline' styles. (See `default-config.yaml`, [#angular/26152](https://github.com/angular/angular/issues/26152))
12+
6. [Disable inline event handler script for styles.](https://github.com/angular/angular-cli/issues/20864#issuecomment-1165769416):
13+
* ```json
14+
{
15+
"...": "...",
16+
"configurations": {
17+
"production": {
18+
"...": "...",
19+
"optimization": {
20+
"scripts": true,
21+
"styles": {
22+
"minify": true,
23+
"inlineCritical": false
24+
},
25+
"fonts": true
26+
}
27+
},
28+
"...": "..."
29+
}
30+
}
31+
```
1232

1333
## Build Dockerfile
1434

examples/angular/angular.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"src/spa_config.js"
3434
],
3535
"styles": [
36-
"src/styles.sass"
36+
"src/styles.scss"
3737
],
3838
"scripts": []
3939
},
@@ -46,7 +46,14 @@
4646
"with": "src/environments/environment.prod.ts"
4747
}
4848
],
49-
"optimization": true,
49+
"optimization": {
50+
"scripts": true,
51+
"styles": {
52+
"minify": true,
53+
"inlineCritical": false
54+
},
55+
"fonts": true
56+
},
5057
"outputHashing": "all",
5158
"sourceMap": false,
5259
"namedChunks": false,
@@ -96,7 +103,7 @@
96103
"src/assets"
97104
],
98105
"styles": [
99-
"src/styles.sass"
106+
"src/styles.scss"
100107
],
101108
"scripts": []
102109
}

examples/angular/src/app/app.component.sass

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
margin-bottom: 10px;
3+
}

examples/angular/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Component } from '@angular/core';
33
@Component({
44
selector: 'app-root',
55
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.sass']
6+
styleUrls: ['./app.component.scss']
77
})
88
export class AppComponent {
99
title = window.spaConfig.appTitle;

examples/angular/src/styles.sass

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/angular/src/styles.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
margin: 10px;
3+
}

0 commit comments

Comments
 (0)