Skip to content

fix(ui): use explicit relative paths for internal SCSS imports v4#16828

Merged
AlessioGr merged 1 commit into
payloadcms:mainfrom
haxllo:fix/ui-scss-relative-imports
Jun 7, 2026
Merged

fix(ui): use explicit relative paths for internal SCSS imports v4#16828
AlessioGr merged 1 commit into
payloadcms:mainfrom
haxllo:fix/ui-scss-relative-imports

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, +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.

-@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).

Replace bare @import statements ('vars', 'z-index', 'queries', 'svg',
'styles') with explicit './' relative paths. The bare form is fragile
across Sass loader configurations: it works when the loader adds the
current file's directory to the load path, but fails under
Turbopack/Next.js 16 with resolve-url-loader and some webpack sass
configurations, producing:

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

This addresses payloadcms#15011 and payloadcms#16037 where the dist
shipped from build artifacts of the same src files caused the same
error on Windows + Next.js 16. The fix in src ensures the rebuilt
dist will be correct.
@haxllo

haxllo commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

@AlessioGr

@AlessioGr AlessioGr enabled auto-merge (squash) June 7, 2026 00:05
@AlessioGr AlessioGr merged commit 2ebbf07 into payloadcms:main Jun 7, 2026
488 of 493 checks passed
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