stencil icon indicating copy to clipboard operation
stencil copied to clipboard

Stencil imports only one stylesheet

Open ghost opened this issue 5 years ago • 7 comments

Stencil version:

"@stencil/core": "^1.11.3"

I'm submitting a:

[ X] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior: When I try to import a few "css" files, only the first one is applied.

styleUrls: [
    'my-component.css',
    'another-styles.css', // These styles will not apply
  ],

Expected behavior: All styles specified in the styleUrls are working.

Steps to reproduce: Use https://github.com/KhaydarshinAleksandr/stencil-example/blob/master/src/components/my-component/my-component.tsx

Other information: In version 1.9.0, the bug does not present

ghost avatar Apr 01 '20 11:04 ghost

@KhaydarshinAleksandr That's not quite how the styleUrls property works. It's for setting alternate stylesheets based on the component's mode. Take a look at this example.

If you want to import multiple stylesheets, I think the easiest would be to do the imports in your CSS files, instead of the component TSX.

alex-ketch avatar Apr 02 '20 19:04 alex-ketch

@alex-ketch, thank you for reply. I think that since interface styleUrls looks like styleUrls?: string[] | d.ModeStyles; , we can use multiple stylesheets at once. Moreover it worked in earlier versions.

But your approach can be used as a temporary solution, thanks

ghost avatar Apr 03 '20 07:04 ghost

@KhaydarshinAleksandr is right, the typings indicate that multiple stylesheets can be loaded. I use it to structure component styles for different viewports/media queries. It's also not quite obvious how mode styles can be defined as arrays, instead of key-value pairs of mode name and url (d.ModeStyles)...

davidenke avatar Apr 25 '20 20:04 davidenke

Any updates of this issue?

I don't want do import in CSS files

ghost avatar Jun 06 '20 07:06 ghost

My problem when importing the CSS files is that firefox applies the CSS after my inline so the external CSS (i.e. bootstrap) overrides my internal CSS w/ my custom bootstrap overrides. If I could get the

LukePammant avatar Aug 31 '21 16:08 LukePammant

👋 If someone would be willing/able to create a minimal reproduction case with the latest version of Stencil, the team would be happy to take a look. It appears the original repro has disappeared, likely due to the time it took for someone to ack this ticket 😢

rwaskiewicz avatar Aug 26 '22 13:08 rwaskiewicz

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Aug 26 '22 13:08 ionitron-bot[bot]

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil!

ionitron-bot[bot] avatar Sep 25 '22 13:09 ionitron-bot[bot]