Unverified Commit e5202ffb authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add CSS fixture for src dir (#9001)

* Add CSS fixture for src dir

* Revert relative customAppFile dir and update tests
parent 13f05f2c
......@@ -664,7 +664,7 @@ export default async function getBaseWebpackConfig(
'Custom <App>'
)}. Please move all global CSS imports to ${chalk.cyan(
customAppFile
? path.relative(pagesDir, customAppFile)
? path.relative(dir, customAppFile)
: 'pages/_app.js'
)}.\n` +
`Read more: https://err.sh/next.js/global-css`,
......
import React from 'react'
import App from 'next/app'
import '../../styles/global.css'
class MyApp extends App {
render () {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp
export default function Home () {
return <div className='red-text'>This text should be red.</div>
}
......@@ -44,6 +44,30 @@ describe('CSS Support', () => {
})
})
describe('Basic Global Support with src/ dir', () => {
const appDir = join(fixturesDir, 'single-global-src')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should build successfully', async () => {
await nextBuild(appDir)
})
it(`should've emitted a single CSS file`, async () => {
const cssFolder = join(appDir, '.next/static/css')
const files = await readdir(cssFolder)
const cssFiles = files.filter(f => /\.css$/.test(f))
expect(cssFiles.length).toBe(1)
expect(await readFile(join(cssFolder, cssFiles[0]), 'utf8')).toContain(
'color:red'
)
})
})
describe('Multi Global Support', () => {
const appDir = join(fixturesDir, 'multi-global')
......@@ -194,7 +218,9 @@ describe('CSS Support', () => {
})
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toContain('Please move all global CSS imports')
expect(stderr).toMatch(
/Please move all global CSS imports.*?pages(\/|\\)_app/
)
})
})
......@@ -211,7 +237,9 @@ describe('CSS Support', () => {
})
expect(stderr).toContain('Failed to compile')
expect(stderr).toContain('styles/global.css')
expect(stderr).toContain('Please move all global CSS imports')
expect(stderr).toMatch(
/Please move all global CSS imports.*?pages(\/|\\)_app/
)
})
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment