Skip to content

Commit

Permalink
docs: next.config.js (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
agerard-godaddy authored Dec 6, 2024
1 parent 73f94bb commit 0fe8764
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
11 changes: 11 additions & 0 deletions docs/upgrade-to-7.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ of Next.js.
You can reference the [Next.js 14] and [Next.js 13] Upgrade Guides as needed
for more details.

In order for Next.js configurations from plugins or `nextConfig` in the
`gasket.js` file to be picked up, you will need to create a `next.config.js`
file in the root of your project and export the results of the
`getNextConfig` GasketAction.

```js
// next.config.js
import gasket from './gasket.js';
export default gasket.actions.getNextConfig();
````

## Switch to GasketActions

Using the `req` and `res` objects for adding attachments and accessing data has
Expand Down
52 changes: 23 additions & 29 deletions packages/gasket-plugin-nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,40 @@ export default makeGasket({
});
```

## Adding a Sitemap

When creating a new application with this plugin, you will be prompted with a question in the CLI asking if you would like to add a [sitemap] to your application.

Answering yes to this question will install `next-sitemap` as a dependency, generate a next-sitemap.config.js file, and add a `sitemap` npm script to your package.json. `next-sitemap` is an npm package that generates sitemaps and a robots.txt file for Next.js applications. Learn more by reading the [next-sitemap docs].

## Configuration

- Instead of adding a dedicated `next.config.js`, the `nextConfig` property
within `gasket.js` is used. Everything you can configure in the
[next.config] can be added here.

It is also possible for apps to config Next.js using the `gasket.js`
file. To do so, specify a `nextConfig` object property in the same form as what
you would set for [custom configurations][next.config] or using Next.js plugins.

For general Webpack configurations, it is recommend to utilize features of the
Gasket [webpack plugin].

#### Example configuration
#### Example Gasket configuration

```js
// gasket.js
export default makeGasket({
plugins: [
pluginNextjs
]
],
nextConfig: {
poweredByHeader: false,
useFileSystemPublicRoutes: false
}
});
```

#### Example with plugins
In order for Next.js to pick up the configurations, you will need to create a
`next.config.js` file in the root of your project and export the results of the
[getNextConfig] action.

```js
import withSass from '@zeit/next-sass';
import withCss from '@zeit/next-css';

export default makeGasket({
plugins: [
pluginNextjs
]
nextConfig: withCss(
withSass({
/* config options here */
})
)
});
// next.config.js
import gasket from './gasket.js';
export default gasket.actions.getNextConfig();
```

For general Webpack configurations, it is recommended to use features of the
Gasket [Webpack plugin], which will be merged into the Next.js configuration.

### Internationalized Routing

When using this plugin along with [@gasket/plugin-intl] to determine and provide
Expand Down Expand Up @@ -115,6 +98,16 @@ Also note when using [@gasket/plugin-intl] to determine the locale, that the
`NEXT_LOCALE` cookie will have no effect. You can, of course, hook the [intlLocale]
lifecycle in an app to enable that behavior if desired.

## Adding a Sitemap

When creating a new application with this plugin, you will be prompted with a
question in the CLI asking if you would like to add a [sitemap] to your application.

Answering yes to this question will install `next-sitemap` as a dependency,
generate a next-sitemap.config.js file, and add a `sitemap` npm script to your
package.json. `next-sitemap` is an npm package that generates sitemaps and a
robots.txt file for Next.js applications. Learn more by reading the [next-sitemap docs].

## Actions

### getNextConfig
Expand Down Expand Up @@ -281,6 +274,7 @@ export default {
<!--[next.config]-->

[nextconfig lifecycle]: #nextconfig
[getNextConfig]: #getnextconfig
[@gasket/plugin-intl]: /packages/gasket-plugin-intl/README.md
[intllocale]: /packages/gasket-plugin-intl/README.md#intllocale
[webpack plugin]: /packages/gasket-plugin-webpack/README.md
Expand Down

0 comments on commit 0fe8764

Please sign in to comment.