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
a3eec3bf
Unverified
Commit
a3eec3bf
authored
Jul 27, 2020
by
Tim Neutkens
Committed by
GitHub
Jul 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update custom webpack config docs to mention existing features (#15517)
parent
1ee15164
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
50 deletions
+13
-50
custom-webpack-config.md
docs/api-reference/next.config.js/custom-webpack-config.md
+10
-8
next.config.js
examples/with-ant-design/next.config.js
+3
-42
No files found.
docs/api-reference/next.config.js/custom-webpack-config.md
View file @
a3eec3bf
...
...
@@ -4,12 +4,18 @@ description: Extend the default webpack config added by Next.js.
# Custom Webpack Config
Before continuing to add custom webpack configuration your application make sure Next.js doesn't already support your use-case:
-
[
CSS imports
](
/docs/basic-features/built-in-css-support#adding-a-global-stylesheet
)
-
[
CSS modules
](
/docs/basic-features/built-in-css-support#adding-component-level-css
)
-
[
Sass/SCSS imports
](
/docs/basic-features/built-in-css-support#sass-support
)
-
[
Sass/SCSS modules
](
/docs/basic-features/built-in-css-support#sass-support
)
-
[
preact
](
https://github.com/vercel/next.js/tree/canary/examples/using-preact
)
-
[
Customizing babel configuration
](
/docs/advanced-features/customizing-babel-config
)
Some commonly asked for features are available as plugins:
-
[
@zeit/next-sass
](
https://github.com/zeit/next-plugins/tree/master/packages/next-sass
)
-
[
@zeit/next-less
](
https://github.com/zeit/next-plugins/tree/master/packages/next-less
)
-
[
@zeit/next-stylus
](
https://github.com/zeit/next-plugins/tree/master/packages/next-stylus
)
-
[
@zeit/next-preact
](
https://github.com/zeit/next-plugins/tree/master/packages/next-preact
)
-
[
@next/mdx
](
https://github.com/vercel/next.js/tree/canary/packages/next-mdx
)
-
[
@next/bundle-analyzer
](
https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer
)
...
...
@@ -20,12 +26,8 @@ module.exports = {
webpack
:
(
config
,
{
buildId
,
dev
,
isServer
,
defaultLoaders
,
webpack
})
=>
{
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
// Important: return the modified config
config
.
plugins
.
push
(
new
webpack
.
IgnorePlugin
(
/
\/
__tests__
\/
/
))
return
config
},
webpackDevMiddleware
:
(
config
)
=>
{
// Perform customizations to webpack dev middleware config
// Important: return the modified config
return
config
},
...
...
examples/with-ant-design/next.config.js
View file @
a3eec3bf
const
compose
=
(
plugins
)
=>
({
webpack
(
config
,
options
)
{
return
plugins
.
reduce
((
config
,
plugin
)
=>
{
if
(
plugin
instanceof
Array
)
{
const
[
_plugin
,
...
args
]
=
plugin
plugin
=
_plugin
(...
args
)
}
if
(
plugin
instanceof
Function
)
{
plugin
=
plugin
()
}
if
(
plugin
&&
plugin
.
webpack
instanceof
Function
)
{
return
plugin
.
webpack
(
config
,
options
)
}
return
config
},
config
)
},
webpackDevMiddleware
(
config
)
{
return
plugins
.
reduce
((
config
,
plugin
)
=>
{
if
(
plugin
instanceof
Array
)
{
const
[
_plugin
,
...
args
]
=
plugin
plugin
=
_plugin
(...
args
)
}
if
(
plugin
instanceof
Function
)
{
plugin
=
plugin
()
}
if
(
plugin
&&
plugin
.
webpackDevMiddleware
instanceof
Function
)
{
return
plugin
.
webpackDevMiddleware
(
config
)
}
return
config
},
config
)
},
const
withBundleAnalyzer
=
require
(
'@next/bundle-analyzer'
)({
enabled
:
process
.
env
.
ANALYZE
===
'true'
,
})
const
withBundleAnalyzer
=
require
(
'@next/bundle-analyzer'
)
module
.
exports
=
compose
([
[
withBundleAnalyzer
,
{
enabled
:
process
.
env
.
ANALYZE
===
'true'
,
},
],
])
module
.
exports
=
withBundleAnalyzer
()
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