Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-source-filesystem): Expose usePolling option #36975

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/gatsby-source-filesystem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ module.exports = {

## Options

In addition to the name and path parameters you may pass an optional `ignore` array of file globs to ignore.
### name

The name of the fileset when querying file nodes from graphql.

### path

The path to the files (e.g. `${__dirname}/content/blog`)

### ignore

You may pass an optional `ignore` array of file globs to ignore.

They will be added to the following default list:

Expand All @@ -62,7 +72,9 @@ They will be added to the following default list:
../**/dist/**
```

To prevent concurrent requests overload of `processRemoteNode`, you can adjust the `200` default concurrent downloads, with `GATSBY_CONCURRENT_DOWNLOAD` environment variable.
### usePolling

Configure the `usePolling` option of https://github.com/paulmillr/chokidar

## How to query

Expand Down Expand Up @@ -193,6 +205,8 @@ createRemoteFileNode({
})
```

To prevent concurrent requests overload of `processRemoteNode`, you can adjust the `200` default concurrent downloads, with `GATSBY_CONCURRENT_DOWNLOAD` environment variable.

#### Example usage

The following example is pulled from [gatsby-source-wordpress](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-wordpress). Downloaded files are created as `File` nodes and then linked to the WordPress Media node, so it can be queried both as a regular `File` node and from the `localFile` field in the Media node.
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby-source-filesystem/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ exports.pluginOptionsSchema = ({ Joi }) =>
Joi.object().regex(),
Joi.function()
),
usePolling: Joi.boolean()
.default(false)
.description(
`Configure the "usePolling" option of https://github.com/paulmillr/chokidar`
),
})

exports.sourceNodes = (api, pluginOptions) => {
Expand Down Expand Up @@ -202,6 +207,7 @@ See docs here - https://www.gatsbyjs.com/plugins/gatsby-source-filesystem/
`../**/dist/**`,
...(pluginOptions.ignore || []),
],
usePolling: pluginOptions.usePolling,
})

watcher.on(`add`, path => {
Expand Down