Skip to content

Commit 7ca8b05

Browse files
authored
fix(templates): remove tilde SCSS imports and add Sass loadPaths for 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>
1 parent 474eda2 commit 7ca8b05

9 files changed

Lines changed: 21 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"lint": "turbo run lint --log-order=grouped --continue --filter \"!blank\" --filter \"!website\" --filter \"!ecommerce\"",
9090
"lint-staged": "lint-staged",
9191
"lint:fix": "turbo run lint:fix --log-order=grouped --continue --filter \"!blank\" --filter \"!website\" --filter \"!ecommerce\"",
92-
"lint:scss": "stylelint \"packages/ui/src/**/*.scss\"",
92+
"lint:scss": "stylelint \"packages/ui/src/**/*.scss\" \"templates/**/*.scss\"",
9393
"obliterate-playwright-cache-macos": "rm -rf ~/Library/Caches/ms-playwright && find /System/Volumes/Data/private/var/folders -type d -name 'playwright*' -exec rm -rf {} +",
9494
"prepare": "husky && pnpm turbo build --filter @payloadcms/typescript-plugin",
9595
"prepare-run-test-against-prod": "pnpm bf && rm -rf test/packed && rm -rf test/node_modules && rm -rf app && rm -f test/pnpm-lock.yaml && pnpm run script:pack --all --no-build --dest test/packed && pnpm runts test/setupProd.ts && cd test && pnpm i --ignore-workspace && cd ..",

templates/ecommerce/next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { redirects } from './redirects'
1010
const NEXT_PUBLIC_SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:3000'
1111

1212
const nextConfig: NextConfig = {
13+
// Temporarily required on Windows until Next.js fixes Turbopack Sass resolution.
14+
// See: https://github.com/vercel/next.js/issues/86431
15+
sassOptions: {
16+
loadPaths: ['./node_modules/@payloadcms/ui/dist/scss/'],
17+
},
1318
images: {
1419
localPatterns: [
1520
{

templates/ecommerce/src/components/BeforeDashboard/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~@payloadcms/ui/scss';
1+
@import '@payloadcms/ui/scss';
22

33
.dashboard .before-dashboard {
44
margin-bottom: base(1.5);

templates/website/next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ const NEXT_PUBLIC_SERVER_URL = process.env.VERCEL_PROJECT_PRODUCTION_URL
1212
: process.env.__NEXT_PRIVATE_ORIGIN || 'http://localhost:3000'
1313

1414
const nextConfig: NextConfig = {
15+
// Temporarily required on Windows until Next.js fixes Turbopack Sass resolution.
16+
// See: https://github.com/vercel/next.js/issues/86431
17+
sassOptions: {
18+
loadPaths: ['./node_modules/@payloadcms/ui/dist/scss/'],
19+
},
1520
images: {
1621
localPatterns: [
1722
{

templates/website/src/components/AdminBar/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~@payloadcms/ui/scss';
1+
@import '@payloadcms/ui/scss';
22

33
.admin-bar {
44
@include small-break {

templates/website/src/components/BeforeDashboard/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~@payloadcms/ui/scss';
1+
@import '@payloadcms/ui/scss';
22

33
.dashboard .before-dashboard {
44
margin-bottom: base(1.5);

templates/with-vercel-website/next.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ const NEXT_PUBLIC_SERVER_URL = process.env.VERCEL_PROJECT_PRODUCTION_URL
1212
: process.env.__NEXT_PRIVATE_ORIGIN || 'http://localhost:3000'
1313

1414
const nextConfig: NextConfig = {
15+
// Temporarily required on Windows until Next.js fixes Turbopack Sass resolution.
16+
// See: https://github.com/vercel/next.js/issues/86431
17+
sassOptions: {
18+
loadPaths: ['./node_modules/@payloadcms/ui/dist/scss/'],
19+
},
1520
images: {
1621
localPatterns: [
1722
{

templates/with-vercel-website/src/components/AdminBar/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~@payloadcms/ui/scss';
1+
@import '@payloadcms/ui/scss';
22

33
.admin-bar {
44
@include small-break {

templates/with-vercel-website/src/components/BeforeDashboard/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '~@payloadcms/ui/scss';
1+
@import '@payloadcms/ui/scss';
22

33
.dashboard .before-dashboard {
44
margin-bottom: base(1.5);

0 commit comments

Comments
 (0)