Skip to content

fix(ui): use explicit relative paths for internal SCSS imports v3.x#16827

Merged
AlessioGr merged 1 commit into
payloadcms:3.xfrom
haxllo:3.x
Jun 7, 2026
Merged

fix(ui): use explicit relative paths for internal SCSS imports v3.x#16827
AlessioGr merged 1 commit into
payloadcms:3.xfrom
haxllo:3.x

Conversation

@haxllo

@haxllo haxllo commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What?

Replace bare @import statements in @payloadcms/ui SCSS entry points with explicit ./-prefixed relative paths. Three files changed, +9 / -9 lines on 3.x.

File Imports fixed
packages/ui/src/scss/styles.scss vars, z-index, type, queries, resets, svg
packages/ui/src/scss/toastify.scss vars, queries
packages/ui/src/scss/app.scss styles

Why?

Bare @import resolution depends on the Sass loader adding the current file's directory to the load path. This is true for the legacy node-sass and some sass-loader configurations, but not for:

  • Turbopack + resolve-url-loader (Next.js 16 default)
  • Some webpack sass-loader setups with restricted include paths
  • Standalone sass CLI runs that don't pre-add the SCSS directory

In those environments, the build fails with:

Error evaluating Node.js code
Error: Can't find stylesheet to import.
  ╷
1 │ @import 'vars';
  │         ^^^^^^╡

The dist/ published to npm is built from these src/ files via pnpm copyfiles, so every released 3.x version ships the same fragile dist. Today the only working workaround is a downstream pnpm.patchedDependencies patch (see #15011$

How?

Mechanical, byte-for-byte equivalent refactor: prefix each internal bare @import with ./. No new files, no deletions, no JS / TS / API changes. Output CSS is identical.

-@import 'vars';
+@import './vars';

After this lands, downstream projects can drop the pnpm patch workaround and bump to the next 3.x release.

Reproduction (before)

  1. npx create-payload-app@latest (any 3.x template)
    1. pnpm install && pnpm dev
  2. Open the admin panel

Result on Windows + Next.js 16 + Turbopack: admin panel fails to render, log shows the @import 'vars' error. Confirmed in #15011 and a follow-up in #16037.

Reproduction (after)

Same steps - admin panel renders cleanly. pnpm.patchedDependencies patch is no longer required.

Backward compatibility

Pure SCSS source refactor. Compiled CSS is byte-identical. No runtime, API, or public surface change. Safe for patch releases.

Related #16037, #15011

Replace bare @import statements in @payloadcms/ui SCSS entry points
with explicit './'-prefixed relative paths. The bare form depends on
the Sass loader adding the current file's directory to the load path,
which is not guaranteed across configurations. Under
Turbopack/Next.js 16 with resolve-url-loader, this fails with:

  Error: Can't find stylesheet to import.
  @import 'vars';

The dist/ shipped to npm is built from these src/ files via pnpm
copyfiles, so every published 3.x release inherits the fragility and
requires a downstream pnpm.patchedDependencies patch to resolve.

Affected files:
  - packages/ui/src/scss/styles.scss (4 imports)
  - packages/ui/src/scss/toastify.scss (2 imports)
  - packages/ui/src/scss/app.scss (1 import)

Output CSS is byte-identical; only the import path form changes.
Pure style-sheet refactor, no public API or runtime change.

Fixes payloadcms#15011
Related payloadcms#16037
@AlessioGr AlessioGr merged commit c039e55 into payloadcms:3.x Jun 7, 2026
337 of 341 checks passed
AlessioGr pushed a commit that referenced this pull request Jun 7, 2026
…6828)

### What?

Replace bare `@import` statements in `@payloadcms/ui` SCSS entry points
with explicit `./`-prefixed relative paths. Three files changed, **+7 /
-7 lines** on `main` (v4).

| File | Imports fixed |
|---|---|
| `packages/ui/src/scss/styles.scss` | `vars`, `z-index`, `queries`,
`svg` |
| `packages/ui/src/scss/toastify.scss` | `vars`, `queries` |
| `packages/ui/src/scss/app.scss` | `styles` |

### Why?

Bare `@import` resolution depends on the Sass loader adding the current
file's directory to the load path. This is **not** true for:

- Turbopack + `resolve-url-loader` (Next.js 16 default)
- Some webpack `sass-loader` setups with restricted `include` paths
- Standalone `sass` CLI runs that don't pre-add the SCSS directory

In those environments, the build fails with:

```
Error evaluating Node.js code
Error: Can't find stylesheet to import.
  ╷
1 │ @import 'vars';
  │         ^^^^^^╡
```

The `dist/` published to npm is built from these `src/` files via `pnpm
copyfiles`, so the same fragile dist ships in every release. A published
package should not require a downstream patch to compile.

### How?

Mechanical, byte-for-byte equivalent refactor: prefix each internal bare
`@import` with `./`. No new files, no deletions, no JS / TS / API
changes. Output CSS is identical.

```diff
-@import 'vars';
+@import './vars';
```

### Backward compatibility

Pure SCSS source refactor. Compiled CSS is byte-identical. No runtime,
API, or public surface change.

### Follow-up (separate PR)

The legacy `@import` rule itself is deprecated in Dart Sass 3.0 (the
codebase already emits `DEPRECATION WARNING [import]` on every build). A
future PR should migrate the whole SCSS tree to `@use` / `@forward`.
This PR keeps the diff min$

Relates to #15011  (tracked on 3.x; same fix applied in 3.x PR #16827).
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.85.1

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