fix(ui): invalid sass imports to support windows - add Stylelint to prevent regression#15028
Conversation
Fixes invalid Sass import paths in the compiled @payloadcms/ui output that currently rely on legacy webpack resolution behavior.
|
@rubixvi Thank you so much for this! I was stuck on the same error :) |
|
@rubixvi Thank you so much for this workaround, hope they will check for this soon! |
There was a problem hiding this comment.
Pull request overview
This PR fixes invalid Sass import paths that relied on legacy webpack tilde (~) resolution behavior, which causes issues on Windows. The fix replaces tilde imports with relative paths and adds stylelint tooling to prevent future regressions.
Key Changes:
- Replaced tilde-prefixed SCSS imports (
~@payloadcms/ui/scss) with relative paths (../../scss/styles) - Added stylelint with a custom plugin to enforce relative paths and prevent tilde imports
- Configured CI workflow to run SCSS linting alongside JavaScript/TypeScript linting
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/ui/src/widgets/CollectionCards/index.scss |
Updated import from tilde syntax to relative path with .scss extension |
packages/ui/src/providers/LivePreview/index.scss |
Updated import from tilde syntax to relative path without extension |
package.json |
Added stylelint, postcss, and postcss-scss dev dependencies, plus new lint:scss script |
pnpm-lock.yaml |
Lock file updates for new stylelint and postcss dependencies |
.stylelintrc.json |
New stylelint configuration with custom plugin for tilde import detection |
.stylelint/no-tilde-imports.js |
Custom stylelint plugin to detect and report tilde imports in SCSS |
.vscode/settings.json |
Enabled stylelint with auto-fix on save for CSS/SCSS files |
.vscode/extensions.json |
Added stylelint VS Code extension recommendation |
.github/workflows/main.yml |
Added SCSS linting step to CI workflow |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
🚀 This is included in version v3.70.0 |
|
I haven't had access to a Windows device to verify the fix. Can anyone confirm if this has been fixed in v3.70? |
It's fine. |
…revent regression (#15028) Fixes invalid Sass import paths in the compiled @payloadcms/ui output that currently rely on legacy webpack resolution behavior. Fixes issue #15011 ``` ./nodemodules/.pnpm/@payloadcms+ui@3.69.0@type_f6dae4b1d169b9370a166162f9bf6e5f/node_modules/@payloadcms/ui/dist/widgets/CollectionCards/index.scss Error evaluating Node.js code Error: Can't find stylesheet to import. ╷ 1 │ @import 'vars'; │ ^^^^^^ ``` Patch file ``` diff --git a/dist/widgets/CollectionCards/index.scss b/dist/widgets/CollectionCards/index.scss index 0330e9c..c8776a7 100644 --- a/dist/widgets/CollectionCards/index.scss +++ b/dist/widgets/CollectionCards/index.scss @@ -1,4 +1,4 @@ -@import '~@payloadcms/ui/scss'; +@import '../../scss/styles'; @layer payload-default { .collections { ``` Running a patch file to adjust this import fixes the issue. --------- Co-authored-by: German Jablonski <43938777+GermanJablo@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I'm getting this error with the file Should this patch have fixed that file as well? |
might need a full error log to figure out what the error is. |
It's just the default BeforeDashboard component that came with the demo, and an .scss file that's included uses tilde-prefixed SCSS imports as well ( |
I mean if it were shippied with a template, then the fix would need to be applied to the project locally. Because GermanJablo also added in a linter to fix all that within payload upstream. |
Since that file is inside a template, could you explain the steps to reproduce the problem? Did you use |
I'm pretty sure I used create-payload-app, but it was well over a year ago, so it may not exist in the base template anymore. The component that was causing the error was a dashboard insert that had functionality for running a data seed route to populate the database with some dummy data, and I had not modified the file at all since I cloned the template. I'm using Postgres and TurboPack on a Windows device. |
…revent regression (payloadcms#15028) Fixes invalid Sass import paths in the compiled @payloadcms/ui output that currently rely on legacy webpack resolution behavior. Fixes issue payloadcms#15011 ``` ./nodemodules/.pnpm/@payloadcms+ui@3.69.0@type_f6dae4b1d169b9370a166162f9bf6e5f/node_modules/@payloadcms/ui/dist/widgets/CollectionCards/index.scss Error evaluating Node.js code Error: Can't find stylesheet to import. ╷ 1 │ @import 'vars'; │ ^^^^^^ ``` Patch file ``` diff --git a/dist/widgets/CollectionCards/index.scss b/dist/widgets/CollectionCards/index.scss index 0330e9c..c8776a7 100644 --- a/dist/widgets/CollectionCards/index.scss +++ b/dist/widgets/CollectionCards/index.scss @@ -1,4 +1,4 @@ -@import '~@payloadcms/ui/scss'; +@import '../../scss/styles'; @layer payload-default { .collections { ``` Running a patch file to adjust this import fixes the issue. --------- Co-authored-by: German Jablonski <43938777+GermanJablo@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Just used v3.82.0 with "npx create-payload-app@latest -t website ." and payload / website template is still broken out of the box with this issue. Frustrating. |
same for me v3.82.1, all the import in **.scss is same pattern as the patch. switch to WSL Ubuntu is my choice |
|
same for the ecommerce template with 3.82.1 |
|
Can someone explain why this is still happening? It seems it's an issue only on windows, but this fix here is explicit for windows. |
|
Ok, now I understand: payload modules are fixed by this PR, but the templates are still broken on windows. |
|
Thank you all for your comments, for opening an issue, and for your patience. I've opened a PR! |
…Windows (#16295) ## Summary - Removes deprecated tilde (`~`) prefix from `@import` statements in all template SCSS files (`website`, `with-vercel-website`, `ecommerce`). The tilde syntax relies on legacy Webpack resolution behavior and is not supported by Turbopack, which is the default bundler in Next.js 16. - Adds `sassOptions.loadPaths` pointing to `@payloadcms/ui/dist/scss/` in each template's `next.config.ts`. This is a workaround for a Turbopack bug on Windows where Sass fails to resolve sibling imports (e.g. `@import 'vars'`) due to missing `includePaths` and backslash path issues (vercel/next.js#86431). - Expands the `lint:scss` script glob to also cover `templates/**/*.scss`, so the existing `no-tilde-imports` stylelint rule (added in #15028) catches template files going forward. Fixes #16059 ## Disclaimer This bug only reproduces on Windows. We are a Mac-only team and have not been able to reproduce it locally, but the fix aligns with the confirmed community workaround and is consistent with the changes already applied to `packages/ui` in #15028. If the next release still does not resolve the issue for Windows users, I am happy to quickly explore a follow-up PR. ## Test plan - [x] Verify `pnpm run lint:scss` passes (no tilde imports detected) - [ ] Windows users: run `npx create-payload-app@latest -t website` and confirm `npm run dev` no longer throws `Can't find stylesheet to import` - [x] Verify templates still compile correctly on macOS/Linux (no regressions from `loadPaths` addition) Co-authored-by: German Jablonski <GermanJablo@users.noreply.github.com>
…Windows (payloadcms#16295) ## Summary - Removes deprecated tilde (`~`) prefix from `@import` statements in all template SCSS files (`website`, `with-vercel-website`, `ecommerce`). The tilde syntax relies on legacy Webpack resolution behavior and is not supported by Turbopack, which is the default bundler in Next.js 16. - Adds `sassOptions.loadPaths` pointing to `@payloadcms/ui/dist/scss/` in each template's `next.config.ts`. This is a workaround for a Turbopack bug on Windows where Sass fails to resolve sibling imports (e.g. `@import 'vars'`) due to missing `includePaths` and backslash path issues (vercel/next.js#86431). - Expands the `lint:scss` script glob to also cover `templates/**/*.scss`, so the existing `no-tilde-imports` stylelint rule (added in payloadcms#15028) catches template files going forward. Fixes payloadcms#16059 ## Disclaimer This bug only reproduces on Windows. We are a Mac-only team and have not been able to reproduce it locally, but the fix aligns with the confirmed community workaround and is consistent with the changes already applied to `packages/ui` in payloadcms#15028. If the next release still does not resolve the issue for Windows users, I am happy to quickly explore a follow-up PR. ## Test plan - [x] Verify `pnpm run lint:scss` passes (no tilde imports detected) - [ ] Windows users: run `npx create-payload-app@latest -t website` and confirm `npm run dev` no longer throws `Can't find stylesheet to import` - [x] Verify templates still compile correctly on macOS/Linux (no regressions from `loadPaths` addition) Co-authored-by: German Jablonski <GermanJablo@users.noreply.github.com>


Fixes invalid Sass import paths in the compiled @payloadcms/ui output that currently rely on legacy webpack resolution behavior.
Fixes issue #15011
Patch file
Running a patch file to adjust this import fixes the issue.