Skip to content

css: false does not disable CSS injection for customElement builds #4124

Closed
@pospi

Description

@pospi

In pursuit of #4117 I'm trying to generate both Svelte and WebComponent versions of my build in a way that retains separation between the style and script bundle. If I use css: false with the default compilation mode this does exactly what I want- add_css is no longer injected into the output component code.

However, when using customElement: true the component still ends up with styles being injected via assignment to this.shadowRoot.innerHTML. So I think there is a possible bug with related questions:

  • Could the compiler be changed such that no CSS is added to customElement versions of components if css: false is specified?
  • If not, is that because there isn't yet a workable way to dynamically inject styles into a WebComponent at runtime?
  • Would it be possible to inject a custom method into the customElement build output that allows such dynamic injection of styles?

Running Svelte 3.16.4; Ubuntu 18.04; Firefox 71. Not using Webpack or Rollup (doing low-level compiler integrations).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions