Skip to content

Commit da3e8cd

Browse files
authored
feat(FEC-14367): add nonce to style tag (#987)
### Description of the Changes add `nonce` attribute to the style tag pushed to DOM. - override the default `insert` behavior of `style-loader` - if `nonce` exists- add it to the style element #### Resolves FEC-14367
1 parent c2ae10f commit da3e8cd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

webpack.config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ module.exports = (env, {mode}) => {
3838
use: [
3939
{
4040
loader: 'style-loader',
41-
options: {attributes: {id: `${packageData.name}`}}
41+
options: {
42+
attributes: {
43+
id: `${packageData.name}`
44+
},
45+
insert: function insertStylesWithNonce(styleElement) {
46+
if (typeof window.kalturaGlobalConfig?.stylesNonce === 'string') {
47+
styleElement.setAttribute('nonce', window.kalturaGlobalConfig.stylesNonce);
48+
}
49+
document.head.appendChild(styleElement);
50+
}
51+
}
4252
},
4353
{
4454
loader: 'css-loader',

0 commit comments

Comments
 (0)