diff --git a/docs/docs/add-custom-webpack-config.md b/docs/docs/add-custom-webpack-config.md index 8280012f13b92..4867b9c9f8522 100644 --- a/docs/docs/add-custom-webpack-config.md +++ b/docs/docs/add-custom-webpack-config.md @@ -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`: diff --git a/examples/using-drupal/gatsby-config.js b/examples/using-drupal/gatsby-config.js index c6abd1fb3365b..9cb6d412d8db5 100644 --- a/examples/using-drupal/gatsby-config.js +++ b/examples/using-drupal/gatsby-config.js @@ -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`, diff --git a/packages/gatsby/src/schema/infer-graphql-input-fields.js b/packages/gatsby/src/schema/infer-graphql-input-fields.js index 2e4aaa3c9189b..59524d647f632 100644 --- a/packages/gatsby/src/schema/infer-graphql-input-fields.js +++ b/packages/gatsby/src/schema/infer-graphql-input-fields.js @@ -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({ @@ -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 }