Skip to content

Commit

Permalink
Import constants from next-server
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilwanner committed Apr 27, 2019
1 parent 4d36b4c commit 1b0b8fc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can also overwrite specific configuration keys for a phase:

```javascript
const withPlugins = require('next-compose-plugins');
const { PHASE_PRODUCTION_BUILD } = require('next/constants');
const { PHASE_PRODUCTION_BUILD } = require('next-server/constants');
const sass = require('@zeit/next-sass');

module.exports = withPlugins([
Expand All @@ -88,16 +88,16 @@ module.exports = withPlugins([

This will overwrite the `cssLoaderOptions` with the new `localIdentName` specified, but **only** during production build.
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`).
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/lib/constants.js).
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/packages/next-server/lib/constants.ts).

##### `phases?: array`

If the plugin should only be applied in specific phases, you can specify them here.
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/lib/constants.js).
You can use all phases [next.js provides](https://github.com/zeit/next.js/blob/canary/packages/next-server/lib/constants.ts).

```javascript
const withPlugins = require('next-compose-plugins');
const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } = require('next/constants');
const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } = require('next-server/constants');
const sass = require('@zeit/next-sass');

module.exports = withPlugins([
Expand All @@ -114,7 +114,7 @@ You can also negate the phases with a leading `!`:

```javascript
const withPlugins = require('next-compose-plugins');
const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } = require('next/constants');
const { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } = require('next-server/constants');
const sass = require('@zeit/next-sass');

module.exports = withPlugins([
Expand Down Expand Up @@ -161,7 +161,7 @@ If you don't use the `optional` helper in this case, you would get an error.

```javascript
const { withPlugins, optional } = require('next-compose-plugins');
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const { PHASE_DEVELOPMENT_SERVER } = require('next-server/constants');

module.exports = withPlugins([
[optional(() => require('@zeit/next-sass')), { /* optional configuration */ }, [PHASE_DEVELOPMENT_SERVER]],
Expand Down Expand Up @@ -212,7 +212,7 @@ However, if you use them, you should mention somewhere in your readme or install
You can specify in which phases your plugin should get executed within the object you return:

```javascript
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const { PHASE_DEVELOPMENT_SERVER } = require('next-server/constants');

module.exports = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
Expand Down Expand Up @@ -315,7 +315,7 @@ const {
PHASE_PRODUCTION_SERVER,
PHASE_DEVELOPMENT_SERVER,
PHASE_EXPORT,
} = require('next/constants');
} = require('next-server/constants');

// next.js configuration
const nextConfig = {
Expand Down

0 comments on commit 1b0b8fc

Please sign in to comment.