Commit 80ed74bc authored by Josh Larson's avatar Josh Larson Committed by Joe Haddad

Add specific warning for require() PostCSS plugin (#10121)

parent 57ec121d
...@@ -193,6 +193,15 @@ export async function getPostCssPlugins( ...@@ -193,6 +193,15 @@ export async function getPostCssPlugins(
} }
throw new Error(genericErrorText) throw new Error(genericErrorText)
} }
} else if (typeof plugin === 'function') {
console.error(
`${chalk.red.bold(
'Error'
)}: A PostCSS Plugin was passed as a function using require(), but it must be provided as a ${chalk.bold(
'string'
)}.`
)
throw new Error(genericErrorText)
} else { } else {
console.error( console.error(
`${chalk.red.bold( `${chalk.red.bold(
......
...@@ -331,6 +331,23 @@ describe('Bad CSS Customization Array (7)', () => { ...@@ -331,6 +331,23 @@ describe('Bad CSS Customization Array (7)', () => {
}) })
}) })
describe('Bad CSS Customization Array (8)', () => {
const appDir = join(fixturesDir, 'bad-custom-configuration-arr-8')
beforeAll(async () => {
await remove(join(appDir, '.next'))
})
it('should fail the build', async () => {
const { stderr } = await nextBuild(appDir, [], { stderr: true })
expect(stderr).toMatch(
/A PostCSS Plugin was passed as a function using require\(\), but it must be provided as a string/
)
expect(stderr).toMatch(/Build error occurred/)
})
})
describe('Bad CSS Customization Function', () => { describe('Bad CSS Customization Function', () => {
const appDir = join(fixturesDir, 'bad-custom-configuration-func') const appDir = join(fixturesDir, 'bad-custom-configuration-func')
......
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
module.exports = {
plugins: [require('postcss-trolling')],
}
/* this should pass through untransformed */
@media (480px <= width < 768px) {
a::before {
content: '';
}
::placeholder {
color: green;
}
}
/* this should be transformed to width/height */
.video {
-xyz-max-size: 400rem 300rem;
}
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