committed by
Mrugesh Mohapatra
parent
b546d8ed92
commit
93debd8892
@ -83,8 +83,26 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.modifyWebpackConfig = ({ config, stage, babelConfig }) => {
|
const generateBabelConfig = require('gatsby/dist/utils/babel-config');
|
||||||
if (stage === 'build-javascript' || stage === 'develop') {
|
|
||||||
|
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, [
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -16,3 +16,12 @@ exports.replaceRenderer = ({
|
|||||||
);
|
);
|
||||||
replaceBodyHTMLString(renderToString(<ConnectedBody />));
|
replaceBodyHTMLString(renderToString(<ConnectedBody />));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.onRenderBody = ({ setPostBodyComponents }) =>
|
||||||
|
setPostBodyComponents([
|
||||||
|
<script
|
||||||
|
async='true'
|
||||||
|
key='chai-CDN'
|
||||||
|
src='https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js'
|
||||||
|
/>
|
||||||
|
]);
|
||||||
|
@ -2,12 +2,18 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
var testTimeout = 5000;
|
var testTimeout = 5000;
|
||||||
var Rx = document.Rx;
|
var Rx = document.Rx;
|
||||||
var frameReady = document.__frameReady;
|
var frameReady = document.__frameReady;
|
||||||
var helpers = Rx.helpers;
|
var chai = parent.chai;
|
||||||
var chai = require('chai');
|
|
||||||
var source = document.__source;
|
var source = document.__source;
|
||||||
var __getUserInput = document.__getUserInput || (x => x);
|
var __getUserInput = document.__getUserInput || (x => x);
|
||||||
var checkChallengePayload = document.__checkChallengePayload;
|
var checkChallengePayload = document.__checkChallengePayload;
|
||||||
|
|
||||||
|
function isPromise(value) {
|
||||||
|
return (
|
||||||
|
value &&
|
||||||
|
typeof value.subscribe !== 'function' &&
|
||||||
|
typeof value.then === 'function'
|
||||||
|
);
|
||||||
|
}
|
||||||
// Fake Deep Equal dependency
|
// Fake Deep Equal dependency
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
||||||
@ -105,7 +111,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
// sync tests can return Any type
|
// sync tests can return Any type
|
||||||
__result = test(getUserInput);
|
__result = test(getUserInput);
|
||||||
|
|
||||||
if (helpers.isPromise(__result)) {
|
if (isPromise(__result)) {
|
||||||
// turn promise into an observable
|
// turn promise into an observable
|
||||||
__result = Rx.Observable.fromPromise(__result);
|
__result = Rx.Observable.fromPromise(__result);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import debugFactory from 'debug';
|
import debugFactory from 'debug';
|
||||||
import { Observable, helpers } from 'rxjs';
|
import { Observable, noop } from 'rxjs';
|
||||||
|
|
||||||
const debug = debugFactory('fcc:ajax$');
|
const debug = debugFactory('fcc:ajax$');
|
||||||
const root = typeof window !== 'undefined' ? window : {};
|
const root = typeof window !== 'undefined' ? window : {};
|
||||||
@ -42,7 +42,7 @@ function getXMLHttpRequest() {
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// purposely do nothing
|
// purposely do nothing
|
||||||
helpers.noop(e);
|
noop.noop(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new root.ActiveXObject(progId);
|
return new root.ActiveXObject(progId);
|
||||||
|
Reference in New Issue
Block a user