You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+230-6
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,14 @@ Provides a cleaner API for enabling and configuring plugins for [next.js](https:
5
5
It is often unclear which plugins are enabled or which configuration belongs to which plugin because they are nested and share one configuration object.
6
6
This can also lead to orphaned configuration values when updating or removing plugins.
7
7
8
-
`next-compose-plugins` tries to eliminate this case by providing an alternative API for enabling and configuring plugins where each plugin has their own configuration object.
8
+
While `next-compose-plugins` tries to eliminate this case by providing an alternative API for enabling and configuring plugins where each plugin has their own configuration object, it also adds more features like phase specific plugins and configuration.
9
9
10
10
## Table of contents
11
11
12
12
-[Installation](#installation)
13
13
-[Usage](#usage)
14
-
-[Example](#example)
14
+
-[Plugin developers](#plugin-developers)
15
+
-[Examples](#examples)
15
16
-[See also](#see-also)
16
17
-[License](#license)
17
18
@@ -21,6 +22,9 @@ This can also lead to orphaned configuration values when updating or removing pl
21
22
npm install --save next-compose-plugins
22
23
```
23
24
25
+
This plugin requires next.js `>= 5.1` because it depends on the phases introduced within this version.
26
+
If you are still on `5.0.x`, you can install v1 of this plugin: `npm install --save next-compose-plugins@1`.
Is an array containing all plugins and their configuration.
38
+
> See the [examples](#examples) for more use-cases.
39
+
40
+
It is an array containing all plugins and their configuration.
35
41
If a plugin does not need additional configuration, you can simply add the imported plugin.
36
-
If it does need configuration, you can specify an array where the first element is the plugin and the second its configuration: `[sass, {mySassConfig: 'foobar'}]` (see [example](#example)).
42
+
If it does need configuration or you only want to run it in a specific phase, you can specify an array:
This will overwrite the `cssLoaderOptions` with the new `localIdentName` specified, but **only** during production build.
87
+
You can also combine multiple phases (`[PHASE_PRODUCTION_BUILD + PHASE_PRODUCTION_SERVER]: {}`) or exclude a phase (`['!' + PHASE_PRODUCTION_BUILD]: {}` which will overwrite the config in all phases except `PRODUCTION_BUILD`).
88
+
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/lib/constants.js).
89
+
90
+
##### `phases?: array`
91
+
92
+
If the plugin should only be applied in specific phases, you can specify them here.
93
+
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/lib/constants.js).
This plugin has a few extra functionality which you can use as a plugin developer.
151
+
However, if you use them, you should mention somewhere in your readme or install instructions that it needs `next-compose-plugins` to have all features available and so it won't confuse your users if something is not working as described out-of-the-box because they don't use this compose plugin yet.
152
+
153
+
### Phases
154
+
155
+
You can specify in which phases your plugin should get executed within the object you return:
As a comparison, it would look like this without this plugin where it is not really clear which configuration belongs to which plugin and what are all the enabled plugins:
As a comparison, it would look like this without this plugin where it is not really clear which configuration belongs to which plugin and what are all the enabled plugins. Many features mentioned above will also not be possible or requires you to have a lot more custom code in your config file.
0 commit comments