Skip to content

bug: dist-custom-elements do not output global styles #6630

@dogoku

Description

@dogoku

Prerequisites

Stencil Version

Any

Current Behavior

Currently only dist and www output global styles, which works as described in the docs.

However, if someone wants to use dist-custom-elements and global styles, they have to use dist or www along with it.

It would be nice if we could either:

  • decouple global styles generation from specific output targets (breaking change, but more preferable)
  • make dist-custom-elements also output global styles (non-breaking, but duplicates css files)

The first option makes more sense, since globalStyles is its own property in the stencil config (same for globalScript). If someone specifies it, it is implied they want it generated, so it shouldn't matter what output targets they are using. And u could even control the output path.

But I would also be ok with the 2nd option, if its easier to implement. Only problem with that is if someone is using 2 or all 3 of the output targets (dist, dist-custom-elements, www), the same css is output in multiple locations for no reason.

Expected Behavior

dist-custom-elements should also output global styles.
Alternatively: When globalStyles is specified in stencil config, styles should be output regardless of output target.

System Info

Steps to Reproduce

  1. npx create-stencil@latest (npm init stencil@latest still errors for me)
  2. add globalStyle: 'src/global/styles.css', to stencil.config.ts.
  3. create ./src/global/styles.css file with some css in it.
  4. remove dist and www from output targets and leave only dist-custom-elements
  5. run npm run build

Code Reproduction URL

https://github.com/dogoku/stencil-global-styles

Additional Information

Related to discussion in #6584

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stencil v5This is slated for Stencil v5 (Release date TBD)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions