Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
5c3f9ba7
Commit
5c3f9ba7
authored
Dec 23, 2019
by
Joe Haddad
Committed by
JJ Kasper
Dec 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Specific Error for Function in PostCSS Config (#9815)
parent
921f7544
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
0 deletions
+45
-0
plugins.ts
packages/next/build/webpack/config/blocks/css/plugins.ts
+6
-0
index.test.js
test/integration/css-customization/test/index.test.js
+17
-0
_app.js
.../css-fixtures/bad-custom-configuration-func/pages/_app.js
+12
-0
index.js
...css-fixtures/bad-custom-configuration-func/pages/index.js
+3
-0
postcss.config.js
...-fixtures/bad-custom-configuration-func/postcss.config.js
+3
-0
global.css
...-fixtures/bad-custom-configuration-func/styles/global.css
+4
-0
No files found.
packages/next/build/webpack/config/blocks/css/plugins.ts
View file @
5c3f9ba7
...
@@ -99,6 +99,12 @@ export async function getPostCssPlugins(
...
@@ -99,6 +99,12 @@ export async function getPostCssPlugins(
config
=
{
plugins
:
getDefaultPlugins
()
}
config
=
{
plugins
:
getDefaultPlugins
()
}
}
}
if
(
typeof
config
===
'function'
)
{
throw
new
Error
(
`Your custom PostCSS configuration may not export a function. Please export a plain object instead.`
)
}
// Warn user about configuration keys which are not respected
// Warn user about configuration keys which are not respected
const
invalidKey
=
Object
.
keys
(
config
).
find
(
key
=>
key
!==
'plugins'
)
const
invalidKey
=
Object
.
keys
(
config
).
find
(
key
=>
key
!==
'plugins'
)
if
(
invalidKey
)
{
if
(
invalidKey
)
{
...
...
test/integration/css-customization/test/index.test.js
View file @
5c3f9ba7
...
@@ -305,3 +305,20 @@ describe('Bad CSS Customization Array (7)', () => {
...
@@ -305,3 +305,20 @@ describe('Bad CSS Customization Array (7)', () => {
expect
(
stderr
).
toMatch
(
/Build error occurred/
)
expect
(
stderr
).
toMatch
(
/Build error occurred/
)
})
})
})
})
describe
(
'Bad CSS Customization Function'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'bad-custom-configuration-func'
)
beforeAll
(
async
()
=>
{
await
remove
(
join
(
appDir
,
'.next'
))
})
it
(
'should fail the build'
,
async
()
=>
{
const
{
stderr
}
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
expect
(
stderr
).
toMatch
(
/Your custom PostCSS configuration may not export a function/
)
expect
(
stderr
).
toMatch
(
/Build error occurred/
)
})
})
test/integration/css-fixtures/bad-custom-configuration-func/pages/_app.js
0 → 100644
View file @
5c3f9ba7
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
test/integration/css-fixtures/bad-custom-configuration-func/pages/index.js
0 → 100644
View file @
5c3f9ba7
export
default
function
Home
()
{
return
<
div
/>
}
test/integration/css-fixtures/bad-custom-configuration-func/postcss.config.js
0 → 100644
View file @
5c3f9ba7
module
.
exports
=
function
()
{
return
{
plugins
:
[]
}
}
test/integration/css-fixtures/bad-custom-configuration-func/styles/global.css
0 → 100644
View file @
5c3f9ba7
/* this should be transformed to width/height */
.video
{
max-size
:
400px
300px
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment