Skip to content

feat(sui-bundler): add plainCssPackages config to bypass sass-loader#1988

Open
tomasmax wants to merge 1 commit into
masterfrom
feat/plain-css-packages-support
Open

feat(sui-bundler): add plainCssPackages config to bypass sass-loader#1988
tomasmax wants to merge 1 commit into
masterfrom
feat/plain-css-packages-support

Conversation

@tomasmax

Copy link
Copy Markdown
Collaborator

Summary

Adds a new plainCssPackages config option to sui-bundler that allows consumer apps to specify npm packages whose .css files should be loaded with only css-loader (and the appropriate style/extract loader), completely bypassing @s-ui/sass-loader and postcss-loader.

Problem

sui-bundler routes all .css and .scss files through the full Sass + PostCSS pipeline — including third-party packages that ship pre-compiled Tailwind CSS v4 output. Dart Sass interprets valid CSS constructs (like transition-property: transform, ...) as Sass spread syntax, causing fatal build errors:

Error: expected ";"
  ╷
  │ transition-property:transform,...;
  │                               ^^^
  ╵

This blocks any consumer app from importing packages that emit modern CSS not compatible with the Sass parser (e.g. @adv-mt/ui which uses Tailwind CSS v4).

Solution

A new config key plainCssPackages under config.sui-bundler in the consumer's package.json:

{
  "config": {
    "sui-bundler": {
      "plainCssPackages": ["@adv-mt/ui", "@adv-mt/theme"]
    }
  }
}

When set, the bundler:

  1. Excludes those packages from the main Sass/PostCSS rule via a regex on node_modules/<package>/
  2. Adds a separate rule that matches only .css files from those packages, using just css-loader (+ MiniCssExtractPlugin.loader or style-loader depending on the webpack config)

Files changed

File Change
shared/module-rules-sass.js Core logic — builds exclude regex, creates separate plain CSS rule, exports array when needed
webpack.config.client.dev.js Uses shared sassRules (was duplicating inline rules)
webpack.config.dev.js Adds plainCssPackages support with style-loader (SPA dev mode)
webpack.config.prod.js Spreads sassRules as array
webpack.config.lib.js Spreads sassRules as array

Usage

// consumer package.json
{
  "config": {
    "sui-bundler": {
      "plainCssPackages": ["@adv-mt/ui"]
    }
  }
}

Then import '@adv-mt/ui/styles.css' works without Sass compilation errors.

Test plan

  • Verified locally: copied broken @adv-mt/ui@2.3.0 CSS into a test app with patched bundler → build passes (no Sass errors)
  • Lint passes (npx sui-lint js — 0 errors)
  • CI (this PR)

🤖 Generated with Claude Code

…s-loader

Adds a new `plainCssPackages` option to `sui-bundler` config that allows
projects to specify npm packages whose CSS files should skip the
sass-loader pipeline entirely.

Packages that ship pre-compiled CSS (e.g. Tailwind CSS v4 output) use
modern CSS syntax (@layer, @Property, nested rules) that Dart Sass
cannot parse. This causes `Error: expected ";"` at build time.

Usage in package.json:
```json
{
  "config": {
    "sui-bundler": {
      "plainCssPackages": ["@adv-mt/ui", "@adv-mt/theme"]
    }
  }
}
```

CSS files from listed packages are processed only by css-loader
(+ MiniCssExtractPlugin or style-loader), bypassing postcss-loader and
sass-loader.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants