Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom page extensions (e.g. page.page.tsx) do not import CSS in AppDir #46702

Open
1 task done
Winwardo opened this issue Mar 2, 2023 · 6 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template.

Comments

@Winwardo
Copy link

Winwardo commented Mar 2, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Introduced in 13.2.2-canary.4
Specifically this change: https://github.com/vercel/next.js/pull/46571 "Fix CSS imports not included in entries with a custom extension"
This change should account for custom page extensions.

Still present in 13.2.4-canary.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://stackblitz.com/edit/vercel-next-js-bxppz3

To Reproduce

In next.config.js, add a custom extension that looks like this:

pageExtensions: ['customextension.tsx', 'customextension.ts'],
This works with any extension of this format, but the version recommended in the stable NextJS docs recommend page.tsx: https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory

Create a page in /app. Import any .css file. See how it does not get imported into the page.

In the reproduction I have given, /app/page.tsx works when there is no custom extension, and /app/page.customextension.tsx does not import the CSS.

Describe the Bug

When not using custom page extensions, pages correctly import CSS:
image

When using a custom page extension, the CSS appears to be dropped completely:
image

I have a legacy NextJS application that relies on a custom extension of page.tsx to allow me to colocate components and other files in the /pages directory, as recommended in the docs.

Due to the size of the project, it is not feasible to migrate to /app or move all the components out of /pages quickly (though it is a long-term goal)

(Side note, the NextJS Typescript plugin also does not understanding custom page extensions - I intend to open a separate issue for that.)

Expected Behavior

CSS should import on files with custom page extensions, like mypage.page.tsx.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@Winwardo Winwardo added the bug Issue was opened via the bug report template. label Mar 2, 2023
@Winwardo Winwardo changed the title Custom page extensions (e.g. page.page.tsx) do not import CSS Custom page extensions (e.g. page.page.tsx) do not import CSS in AppDir Mar 2, 2023
@Winwardo
Copy link
Author

I can confirm this still happens in 13.2.4 and is blocking my ability to upgrade past 13.2.1.
FYI @shuding who has recently worked in this area with your change on CSS imports #46571

Thanks for your time :)

@jinwookie
Copy link

i am encountering the same issue. any updates on this?

@karl-run
Copy link

Also seeing this. I'd like to migrate parts of the pages over to the app dir, disabling the pageExtensions would require moving a bunch of tests and stuff around. 😄

@amannn
Copy link
Contributor

amannn commented May 12, 2023

Can confirm this is still the case in next@13.4.2! I have a similar situation as mentioned above where the page extension would be necessary to migrate an older app.

@karl-run
Copy link

karl-run commented Jun 7, 2023

Seems like this is fixed in either 13.4.3 or 13.4.4. Did a quick test now on 13.4.4. 😅

@karl-run
Copy link

karl-run commented Jun 8, 2023

Correction, seems like tailwind and global CSS works, but not css-modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants