cli: Add support for CSS exports in package build

This adds support for CSS entry points in package exports. When a package
declares a CSS file in its exports field, the CLI will now automatically
bundle it during `backstage-cli package build` and rewrite the export
path from src/ to dist/ at publish time.

The CSS bundling uses lightningcss to resolve @import statements and
preserves @layer declarations that would otherwise be stripped during
bundling.

This allows packages like @backstage/ui to use the standard build command
instead of custom build scripts for CSS bundling.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Patrik Oldsberg
2026-02-09 13:35:19 +01:00
parent 5a5e9bb6bd
commit 4f9d980943
10 changed files with 122 additions and 9369 deletions
+2 -4
View File
@@ -3377,6 +3377,7 @@ __metadata:
jest-css-modules: "npm:^2.1.0"
jsdom: "npm:^27.1.0"
json-schema: "npm:^0.4.0"
lightningcss: "npm:^1.29.1"
lodash: "npm:^4.17.21"
mini-css-extract-plugin: "npm:^2.4.2"
minimatch: "npm:^9.0.0"
@@ -8023,13 +8024,10 @@ __metadata:
"@tanstack/react-table": "npm:^8.21.3"
"@types/react": "npm:^18.0.0"
"@types/react-dom": "npm:^18.0.0"
chalk: "npm:^5.4.1"
clsx: "npm:^2.1.1"
eslint-plugin-storybook: "npm:^10.3.0-alpha.1"
glob: "npm:^11.0.1"
globals: "npm:^15.11.0"
lightningcss: "npm:^1.29.1"
mini-css-extract-plugin: "npm:^2.9.2"
react: "npm:^18.0.2"
react-aria-components: "npm:^1.14.0"
react-dom: "npm:^18.0.2"
@@ -39285,7 +39283,7 @@ __metadata:
languageName: node
linkType: hard
"mini-css-extract-plugin@npm:^2.4.2, mini-css-extract-plugin@npm:^2.9.2":
"mini-css-extract-plugin@npm:^2.4.2":
version: 2.10.0
resolution: "mini-css-extract-plugin@npm:2.10.0"
dependencies: