feat: css source map support

Open
#6,964 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Elements2720 is already working on this.

Since Oct 20, 2026.

  • #6969 by @Elements2720 — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
css, typescript

Research direction

Start by tracing the existing sourceMap option through the build and development pipelines, then inspect how CSS is passed to plugins such as @stencil/sass and through the minifyCss option. The issue proposes extending the option and carrying maps into runtime style tags, including style modes, but names no files or tests. Done means CSS maps work in build and development and can be used by browser developer tools.

Written by the indexing model from the issue text.

Description

Feature: Want this? Upvote it!
Prerequisites
Describe the Feature Request

Add native support for generating CSS source maps during the build and development processes.
Currently, Stencil supports JavaScript/TypeScript source maps, but lacks built-in generation for CSS source maps. This makes it difficult to trace compiled styles back to their original source files within the browser's developer tools.

Describe the Use Case

When developing large-scale design systems with Stencil, styles are often written using complex Sass/PostCSS setups or split across multiple utility files.

CSS source maps will allow developers to inspect an element and see the exact source file, improving the developer experience.

In addition coverage for CSS can be generated and mapped back to the responsible file.

Describe Preferred Solution

the current sourceMap option could be extended:

type SourceMapOption = boolean | {
  css?: boolean,
  js?: boolean,
}

This option must then be pass to plugins like @stencil/sass.

The internal minifier (minifyCss option) must also chain the source map.


to avoid any source map reference comment in the code which could interfere with normal source maps the output component could be extended:

const myComponentCss = () => ``;

const MyComponent = class {};
MyComponent.style = myComponentCss();

MyComponent.sourceMap = 'path to source map or inline source map'; 

the runtime can then inject both the style and sourceMap to the style tag.

to also support style modes the souceMap property can also be an object matching the name of the currently mounted style

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Dominant language
TypeScript
Stars
13.2k
Forks
870
Avg merge
2d 54m
Merged PRs (30d)
50

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stenciljs/core

All issues in stenciljs/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.