Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gatsbyjs/gatsby
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Mar 6, 2018
2 parents 46cc720 + aeb8ff4 commit c782f10
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
32 changes: 32 additions & 0 deletions docs/docs/add-custom-webpack-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@ e.g. [Sass](/packages/gatsby-plugin-sass/),
[Typescript](/packages/gatsby-plugin-typescript/),
[Glamor](/packages/gatsby-plugin-glamor/), and many more!

## Modifying js babel loader

Manually allow tweaking of include + exclude of babel loader.
```
const generateBabelConfig = require( 'gatsby/dist/utils/babel-config' );
...
exports.modifyWebpackConfig = ( { config, stage } ) => {
const program = {
directory: __dirname,
browserslist: [ '> 1%', 'last 2 versions', 'IE >= 9' ]
};
return generateBabelConfig( program, stage )
.then( babelConfig => {
config
.removeLoader( 'js' )
.loader( 'js', {
test: /\.jsx?$/,
exclude: ( modulePath ) => {
return /node_modules/.test( modulePath ) &&
!/node_modules\/(swiper|dom7)/.test( modulePath );
},
loader: 'babel',
query: babelConfig
} );
} );
};
```

## Example

Here is an example that configures **flexboxgrid** when processing css files. Add this in `gatsby-node.js`:
Expand Down
2 changes: 1 addition & 1 deletion examples/using-drupal/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
plugins: [
{
resolve: `gatsby-source-drupal`,
options: { baseUrl: `https://live-contentacms.pantheonsite.io/` },
options: { baseUrl: `https://live-contentacms.pantheonsite.io/`, apiBase: `api` },
},
{
resolve: `gatsby-plugin-google-analytics`,
Expand Down
18 changes: 17 additions & 1 deletion packages/gatsby/src/schema/infer-graphql-input-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ type InferInputOptions = {
exampleValue?: Object,
}

const recursiveOmitBy = (value, fn) => {
if (_.isObject(value)) {
if (_.isPlainObject(value)) {
value = _.omitBy(value, fn)
}
_.each(value, (v, k) => {
value[k] = recursiveOmitBy(v, fn)
})
if (_.isEmpty(value)) {
// don't return empty objects - gatsby doesn't support these
return null
}
}
return value
}

const linkedNodeCache = {}

export function inferInputObjectStructureFromNodes({
Expand Down Expand Up @@ -223,7 +239,7 @@ export function inferInputObjectStructureFromNodes({
node => node.internal.type === linkedNode.internal.type
)
value = extractFieldExamples(relatedNodes)
value = _.omitBy(value, (_v, _k) => _.includes(_k, `___NODE`))
value = recursiveOmitBy(value, (_v, _k) => _.includes(_k, `___NODE`))
linkedNodeCache[linkedNode.internal.type] = value
}

Expand Down

0 comments on commit c782f10

Please sign in to comment.