Stencil version:
I'm submitting a:
Current behavior:
A components currently rely on inline <style> tags. When Content-Security-Policy headers forbid unsafe-inline the styling breaks.
Expected behavior:
Any solution that allows strict CSP policies and well styled Stencil components to coexist.
One approach could be for Stencil to generate CSS files at compilation time to which <style> tags would refer.
Steps to reproduce:
- Take any Stencil component with a
styleUrl specifying some styles
- Compile it and serve it with the following response header added:
Content-Security-Policy = "style-src 'self' ;"
- Notice that styles are broken due to the browser refusing to interpret them
Related code:
The following snippet spins up a proxy from port 5000 to 3333 banning inline style tags. (Assuming express and express-http-proxy are installed.)
const express = require('express');
const proxy = require('express-http-proxy');
const app = express();
app.use((req, res, next) => { res.set('Content-Security-Policy', "style-src 'self' ;"); next(); });
app.use('/', proxy('http://localhost:3333'));
app.listen(5000);
Stencil version:
I'm submitting a:
Current behavior:
A components currently rely on inline
<style>tags. WhenContent-Security-Policyheaders forbidunsafe-inlinethe styling breaks.Expected behavior:
Any solution that allows strict CSP policies and well styled Stencil components to coexist.
One approach could be for Stencil to generate CSS files at compilation time to which
<style>tags would refer.Steps to reproduce:
styleUrlspecifying some stylesContent-Security-Policy = "style-src 'self' ;"Related code:
The following snippet spins up a proxy from port
5000to3333banning inline style tags. (Assumingexpressandexpress-http-proxyare installed.)