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

fixes #48794 : When using pageExtensions like "page.jsx", global css import not working #48795

Merged
merged 10 commits into from Apr 28, 2023
Expand Up @@ -17,7 +17,7 @@ export function getCssInlinedLinkTags(
): string[] {
const layoutOrPageCssModules = serverCSSManifest.cssImports[filePath]

const filePathWithoutExt = filePath.replace(/\.[^.]+$/, '')
const filePathWithoutExt = filePath.replace(/(\.[A-Za-z0-9]+)+$/, '')
const cssFilesForEntry = new Set(
clientReferenceManifest.cssFiles?.[filePathWithoutExt] || []
)
Expand Down
@@ -0,0 +1,7 @@
export default function Page() {
return (
<>
<h1>Page</h1>
</>
)
}
12 changes: 12 additions & 0 deletions test/e2e/app-dir/app-css-pageextensions/app/layout.page.js
@@ -0,0 +1,12 @@
import '../styles/global.css'

export default function Root({ children }) {
return (
<html className="this-is-the-document-html">
<head>
<title>{`hello css`}</title>
</head>
<body className="this-is-the-document-body">{children}</body>
</html>
)
}
29 changes: 29 additions & 0 deletions test/e2e/app-dir/app-css-pageextensions/index.test.ts
@@ -0,0 +1,29 @@
import { createNextDescribe } from 'e2e-utils'

createNextDescribe(
'app dir css with pageextensions',
{
files: __dirname,
skipDeployment: true,
dependencies: {
'@picocss/pico': '1.5.7',
react: 'latest',
'react-dom': 'latest',
sass: 'latest',
},
},
({ next }) => {
describe('css support with pageextensions', () => {
describe('page in app directory with pageextention, css should work', () => {
it('should support global css inside layout', async () => {
const browser = await next.browser('/css-pageextensions')
expect(
await browser.eval(
`window.getComputedStyle(document.querySelector('h1')).color`
)
).toBe('rgb(255, 0, 0)')
})
})
})
}
)
8 changes: 8 additions & 0 deletions test/e2e/app-dir/app-css-pageextensions/next.config.js
@@ -0,0 +1,8 @@
const nextConfig = {
pageExtensions: ['page.jsx', 'page.js'],
experimental: {
appDir: true,
},
}

module.exports = nextConfig
3 changes: 3 additions & 0 deletions test/e2e/app-dir/app-css-pageextensions/styles/global.css
@@ -0,0 +1,3 @@
h1 {
color: red;
}