-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.js
41 lines (35 loc) · 1019 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { composePlugins } from './compose';
import { markOptional } from './optional';
/**
* Composes all plugins together.
*
* @param {array} plugins - all plugins to load and initialize
* @param {object} nextConfig - direct configuration for next.js (optional)
*/
const withPlugins = ([...plugins], nextConfig = {}) => (phase, { defaultConfig }) => {
const config = {
...defaultConfig,
...nextConfig,
};
return composePlugins(phase, plugins, config);
};
/**
* Extends a base next config.
*
* @param {function} baseConfig - basic configuration
*/
const extend = baseConfig => ({
withPlugins: (...params) => (phase, nextOptions) => {
const processedBaseConfig = baseConfig(phase, nextOptions);
return withPlugins(...params)(phase, {
...nextOptions,
defaultConfig: processedBaseConfig,
});
},
});
// define exports
const exports = withPlugins;
exports.withPlugins = withPlugins;
exports.optional = markOptional;
exports.extend = extend;
module.exports = exports;