From 93debd8892f45f97b439d6c0b122c778b3741ced Mon Sep 17 00:00:00 2001 From: Stuart Taylor Date: Mon, 9 Apr 2018 00:11:35 +0100 Subject: [PATCH] Merge pull request #5 from Bouncey/fix/rxHelpers Fix/rx helpers --- packages/learn/gatsby-node.js | 35 +++++++++++-------- packages/learn/gatsby-ssr.js | 9 +++++ packages/learn/src/client/frame-runner.js | 12 +++++-- .../templates/Challenges/utils/ajax-stream.js | 4 +-- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/packages/learn/gatsby-node.js b/packages/learn/gatsby-node.js index 67c6de4704..9d0d046831 100644 --- a/packages/learn/gatsby-node.js +++ b/packages/learn/gatsby-node.js @@ -83,8 +83,26 @@ exports.createPages = ({ graphql, boundActionCreators }) => { }); }; -exports.modifyWebpackConfig = ({ config, stage, babelConfig }) => { - if (stage === 'build-javascript' || stage === 'develop') { +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\/(ansi-styles|chalk)/).test(modulePath) + ); + }, + loader: 'babel', + query: babelConfig + }); config.plugin('CopyWebpackPlugin', CopyWebpackPlugin, [ [ { @@ -93,16 +111,5 @@ exports.modifyWebpackConfig = ({ config, stage, babelConfig }) => { } ] ]); - // remove the default 'js' loader so we can create our own - config.removeLoader('js'); - // these modules are shipped with es6 code, we need to transform them due - // to the version of the uglifyjs plugin gatsby is using - config.loader('js', { - test: /\.jsx?$/, - exclude: /(node_modules|bower_components)\/(?!ansi-styles|chalk)/, - loader: 'babel', - query: babelConfig - }); - } - return config; + }); }; diff --git a/packages/learn/gatsby-ssr.js b/packages/learn/gatsby-ssr.js index ede5d71f75..31853c49ce 100644 --- a/packages/learn/gatsby-ssr.js +++ b/packages/learn/gatsby-ssr.js @@ -16,3 +16,12 @@ exports.replaceRenderer = ({ ); replaceBodyHTMLString(renderToString()); }; + +exports.onRenderBody = ({ setPostBodyComponents }) => + setPostBodyComponents([ +