Skip to content

Commit

Permalink
chore(docs): Use soft wraps for old docs (#20813)
Browse files Browse the repository at this point in the history
* use-soft-line-wraps-for-docs/how-shadowing-works

* use-soft-line-wraps-for-docs/add-404-page

* use-soft-line-wraps-for-docs/add-custom-webpack-config

* use-soft-line-wraps-for-docs/basic-hardware-software-requirements
  • Loading branch information
JijiiMac authored and bball07 committed Jan 23, 2020
1 parent 8208b72 commit d5f6beb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 150 deletions.
21 changes: 5 additions & 16 deletions docs/docs/add-404-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@
title: Adding a 404 Page
---

To create a 404 page create a page whose path matches the regex
`^\/?404\/?$` (`/404/`, `/404`, `404/` or `404`). Most often you'll want to create a React component page at
`src/pages/404.js`.
To create a 404 page create a page whose path matches the regex `^\/?404\/?$` (`/404/`, `/404`, `404/` or `404`). Most often you'll want to create a React component page at `src/pages/404.js`.

Gatsby ensures that your 404 page is built as `404.html` as many static hosting
platforms default to using this as your 404 error page. If you're hosting your
site another way, you'll need to set up a custom rule to serve this file for 404
errors.
Gatsby ensures that your 404 page is built as `404.html` as many static hosting platforms default to using this as your 404 error page. If you're hosting your site another way you'll need to set up a custom rule to serve this file for 404 errors.

Because Gatsby creates this page for you by default, there is no need to configure
it in your `gatsby-node.js` file.
Because Gatsby creates this page for you by default, there is no need to configure it in your `gatsby-node.js` file.

When developing using `gatsby develop`, Gatsby uses a default 404 page that
overrides your custom 404 page. However, you can still preview your 404 page by
clicking "Preview custom 404 page" to verify that it's working as expected. This is
useful when you're developing so that you can see all the available pages.
When developing using `gatsby develop`, Gatsby uses a default 404 page that overrides your custom 404 page. However, you can still preview your 404 page by clicking "Preview custom 404 page" to verify that it's working as expected. This is useful when you're developing so that you can see all the available pages.

The screenshot below shows the default 404 page that Gatsby creates.
It also lists out all the pages on your website. Clicking the "Preview custom 404
page" button will allow you to view the 404 page you created.
The screenshot below shows the default 404 page that Gatsby creates. It also lists out all the pages on your website. Clicking the "Preview custom 404 page" button will allow you to view the 404 page you created.
![Gatsby Default 404 Page](./images/gatsby-default-404.png)

The screenshot below shows the custom 404 page.
Expand Down
43 changes: 13 additions & 30 deletions docs/docs/add-custom-webpack-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,22 @@
title: "Adding a Custom Webpack Config"
---

_Before creating custom webpack configuration, check to see if there's a Gatsby
plugin already built that handles your use case in the
[plugins section](/docs/plugins/). If there's not yet one and your use case is a
general one, it is highly encouraged you to contribute back your plugin to the
Gatsby Plugin Library so it's available to others (including your future self)._

To add custom webpack configurations, create (if there's not one already) a
`gatsby-node.js` file in your root directory. Inside this file, export a
function called `onCreateWebpackConfig`.

When Gatsby creates its webpack config, this function will be called allowing
you to modify the default webpack config using
[webpack-merge](https://github.com/survivejs/webpack-merge).

Gatsby does multiple webpack builds with somewhat different configuration. Gatsby
calls each build type a "stage". The following stages exist:

1. develop: when running the `gatsby develop` command. Has configuration for hot
reloading and CSS injection into page
2. develop-html: same as develop but without react-hmre in the babel config for
rendering the HTML component.
3. build-javascript: production JavaScript and CSS build. Creates route JS bundles as well
as common chunks for JS and CSS.
_Before creating custom webpack configuration, check to see if there's a Gatsby plugin already built that handles your use case in the [plugins section](/docs/plugins/). If there's not yet one and your use case is a general one, it is highly encouraged you to contribute back your plugin to the Gatsby Plugin Library so it's available to others (including your future self)._

To add custom webpack configurations, create (if there's not one already) a `gatsby-node.js` file in your root directory. Inside this file, export a function called `onCreateWebpackConfig`.

When Gatsby creates its webpack config, this function will be called allowing you to modify the default webpack config using [webpack-merge](https://github.com/survivejs/webpack-merge).

Gatsby does multiple webpack builds with somewhat different configuration. Gatsby calls each build type a "stage". The following stages exist:

1. develop: when running the `gatsby develop` command. Has configuration for hot reloading and CSS injection into page
2. develop-html: same as develop but without react-hmre in the babel config for rendering the HTML component.
3. build-javascript: production JavaScript and CSS build. Creates route JS bundles as well as common chunks for JS and CSS.
4. build-html: production build static HTML pages

Check
[webpack.config.js](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/webpack.config.js)
for the source.
Check [webpack.config.js](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/webpack.config.js) for the source.

There are many plugins in the Gatsby repo using this API to look to for examples
e.g. [Sass](/packages/gatsby-plugin-sass/),
[TypeScript](/packages/gatsby-plugin-typescript/),
[Glamor](/packages/gatsby-plugin-glamor/), and many more!
There are many plugins in the Gatsby repo using this API to look to for examples e.g. [Sass](/packages/gatsby-plugin-sass/), [TypeScript](/packages/gatsby-plugin-typescript/), [Glamor](/packages/gatsby-plugin-glamor/), and many more!

## Examples

Expand Down
3 changes: 1 addition & 2 deletions docs/docs/basic-hardware-software-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ title: Basic Hardware and Software Requirements

This is a stub. Help our community expand it.

Please use the [Gatsby Style Guide](/contributing/gatsby-style-guide/) to ensure your
pull request gets accepted.
Please use the [Gatsby Style Guide](/contributing/gatsby-style-guide/) to ensure your pull request gets accepted.
Loading

0 comments on commit d5f6beb

Please sign in to comment.