Skip to content

Commit c039e55

Browse files
authored
fix(ui): use explicit relative paths for internal SCSS imports v3.x (#16827)
### 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. ```diff -@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) 2. 2. `pnpm install && pnpm dev` 3. 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
1 parent 5f40868 commit c039e55

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/ui/src/scss/app.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@layer payload-default, payload;
22

3-
@import 'styles';
3+
@import './styles';
44
@import './toasts.scss';
55
@import './colors.scss';
66

packages/ui/src/scss/styles.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
@import 'vars';
2-
@import 'z-index';
1+
@import './vars';
2+
@import './z-index';
33

44
//////////////////////////////
55
// IMPORT OVERRIDES
66
//////////////////////////////
77

8-
@import 'type';
9-
@import 'queries';
10-
@import 'resets';
11-
@import 'svg';
8+
@import './type';
9+
@import './queries';
10+
@import './resets';
11+
@import './svg';

packages/ui/src/scss/toastify.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@import 'vars';
2-
@import 'queries';
1+
@import './vars';
2+
@import './queries';
33

44
@layer payload-default {
55
.Toastify {

0 commit comments

Comments
 (0)