You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When hot-reloading is enabled, style-loader should add <style> elements with a nonce attribute. The value of the nonce attribute should be the value of __webpack_nonce__.
Actual Behavior
<style> elements do not contain the nonce attribute. Styles are not applied. There is a content-security-policy error in the console, such as the following example.
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'nonce-mysecret'". Either the 'unsafe-inline' keyword, a hash ('sha256-LpjzYvTh3c/ORkLyxZ1XcnY3NdUH2gFMMdyhKwGAaw8='), or a nonce ('nonce-...') is required to enable inline execution.
Expected Behavior
When hot-reloading is enabled,
style-loadershould add<style>elements with anonceattribute. The value of thenonceattribute should be the value of__webpack_nonce__.Actual Behavior
<style>elements do not contain thenonceattribute. Styles are not applied. There is a content-security-policy error in the console, such as the following example.Code
I made a repository to demonstrate this issue at
https://github.com/mgreystone/test-style-loader-nonce/tree/45e3402c342036be2a412e4622802497b7c5dfa8
How Do We Reproduce?
Using hot-reload on webpack-dev-server, load a module that both
__webpack_nonce__ = 'secret'style-loaderUse this on a server that responds a CSP header of `Content-Security-Policy: style-src 'nonce-secret'.