-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update custom webpack config docs to mention existing features (#15517)
- Loading branch information
1 parent
1ee1516
commit a3eec3b
Showing
2 changed files
with
13 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,5 @@ | ||
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() |