update gatsby settings
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
8bfac64d4b
commit
a99325e902
@ -1,22 +1,16 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { ConnectedRouter } from 'react-router-redux';
|
|
||||||
|
|
||||||
import { createStore } from './src/redux/store';
|
import { createStore } from './src/redux/store';
|
||||||
|
|
||||||
exports.replaceRouterComponent = ({ history }) => {
|
export const wrapRootElement = ({ element }) => {
|
||||||
const store = createStore(history || {});
|
const store = createStore();
|
||||||
|
|
||||||
const ConnectedRouterWrapper = ({ children }) => (
|
const ConnectedRootElement = (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ConnectedRouter history={history}>{children}</ConnectedRouter>
|
{element}
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
ConnectedRouterWrapper.displayName = 'ConnectedRouterWrapper';
|
|
||||||
ConnectedRouterWrapper.propTypes = {
|
|
||||||
children: PropTypes.node
|
|
||||||
};
|
|
||||||
|
|
||||||
return ConnectedRouterWrapper;
|
return ConnectedRootElement;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const path = require('path');
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
|
|
||||||
const { dasherize } = require('./utils');
|
const { dasherize } = require('./utils');
|
||||||
const { blockNameify } = require('./utils/blockNameify');
|
const { blockNameify } = require('./utils/blockNameify');
|
||||||
@ -103,71 +101,58 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const RmServiceWorkerPlugin = require('webpack-remove-serviceworker-plugin');
|
const RmServiceWorkerPlugin = require('webpack-remove-serviceworker-plugin');
|
||||||
const generateBabelConfig = require('gatsby/dist/utils/babel-config');
|
|
||||||
|
|
||||||
exports.modifyWebpackConfig = ({ config, stage }) => {
|
exports.onCreateWebpackConfig = ({ rules, plugins, actions }) => {
|
||||||
const program = {
|
actions.setWebpackConfig({
|
||||||
directory: __dirname,
|
module: {
|
||||||
browserslist: ['> 1%', 'last 2 versions', 'IE >= 9']
|
rules: [rules.js({
|
||||||
};
|
/* eslint-disable max-len */
|
||||||
|
exclude: modulePath => {
|
||||||
return generateBabelConfig(program, stage).then(babelConfig => {
|
return (
|
||||||
config.removeLoader('js').loader('js', {
|
/node_modules/.test(modulePath) &&
|
||||||
test: /\.jsx?$/,
|
!(/(ansi-styles|chalk|strict-uri-encode|react-freecodecamp-search)/).test(
|
||||||
/* eslint-disable max-len */
|
modulePath
|
||||||
exclude: modulePath => {
|
)
|
||||||
return (
|
);
|
||||||
/node_modules/.test(modulePath) &&
|
|
||||||
!(/(ansi-styles|chalk|strict-uri-encode|react-freecodecamp-search)/).test(
|
|
||||||
modulePath
|
|
||||||
)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
/* eslint-enable max-len*/
|
|
||||||
loader: 'babel',
|
|
||||||
query: babelConfig
|
|
||||||
});
|
|
||||||
config.plugin('CopyWebpackPlugin', CopyWebpackPlugin, [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, './node_modules/monaco-editor/min/vs'),
|
|
||||||
to: 'vs'
|
|
||||||
}
|
}
|
||||||
|
/* eslint-enable max-len*/
|
||||||
|
})
|
||||||
]
|
]
|
||||||
]);
|
},
|
||||||
config.plugin('DefinePlugin', webpack.DefinePlugin, [
|
node: {
|
||||||
{
|
fs: 'empty'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
plugins.define({
|
||||||
HOME_PATH: JSON.stringify(
|
HOME_PATH: JSON.stringify(
|
||||||
process.env.HOME_PATH || 'http://localhost:3000'
|
process.env.HOME_PATH || 'http://localhost:3000'
|
||||||
),
|
),
|
||||||
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PULIC_KEY || '')
|
STRIPE_PUBLIC_KEY: JSON.stringify(process.env.STRIPE_PUBLIC_KEY || '')
|
||||||
}
|
}),
|
||||||
]);
|
new RmServiceWorkerPlugin()
|
||||||
config.plugin('RemoveServiceWorkerPlugin', RmServiceWorkerPlugin, [
|
]
|
||||||
{ filename: 'sw.js' }
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/* eslint-disable prefer-object-spread/prefer-object-spread */
|
|
||||||
exports.modifyBabelrc = ({ babelrc }) =>
|
exports.onCreateBabelConfig = ({ actions }) => {
|
||||||
Object.assign({}, babelrc, {
|
actions.setBabelPlugin({
|
||||||
plugins: babelrc.plugins.concat([
|
name: '@babel/plugin-proposal-function-bind'
|
||||||
[
|
|
||||||
'transform-es2015-arrow-functions',
|
|
||||||
'transform-imports',
|
|
||||||
'transform-function-bind',
|
|
||||||
{
|
|
||||||
'react-bootstrap': {
|
|
||||||
transform: 'react-bootstrap/lib/${member}',
|
|
||||||
preventFullImport: true
|
|
||||||
},
|
|
||||||
lodash: {
|
|
||||||
transform: 'lodash/${member}',
|
|
||||||
preventFullImport: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
])
|
|
||||||
});
|
});
|
||||||
|
actions.setBabelPlugin({
|
||||||
|
name: '@babel/plugin-proposal-export-default-from'
|
||||||
|
});
|
||||||
|
actions.setBabelPlugin({
|
||||||
|
name: 'babel-plugin-transform-imports',
|
||||||
|
options: {
|
||||||
|
'react-bootstrap': {
|
||||||
|
transform: 'react-bootstrap/lib/${member}',
|
||||||
|
preventFullImport: true
|
||||||
|
},
|
||||||
|
lodash: {
|
||||||
|
transform: 'lodash/${member}',
|
||||||
|
preventFullImport: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -6,7 +6,7 @@ import headComponents from './src/head';
|
|||||||
|
|
||||||
import { createStore } from './src/redux/store';
|
import { createStore } from './src/redux/store';
|
||||||
|
|
||||||
exports.replaceRenderer = ({
|
export const replaceRenderer = ({
|
||||||
history,
|
history,
|
||||||
bodyComponent,
|
bodyComponent,
|
||||||
replaceBodyHTMLString
|
replaceBodyHTMLString
|
||||||
@ -19,7 +19,7 @@ exports.replaceRenderer = ({
|
|||||||
replaceBodyHTMLString(renderToString(<ConnectedBody />));
|
replaceBodyHTMLString(renderToString(<ConnectedBody />));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
|
export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
|
||||||
setHeadComponents([...headComponents]);
|
setHeadComponents([...headComponents]);
|
||||||
setPostBodyComponents([
|
setPostBodyComponents([
|
||||||
<script
|
<script
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.0.0",
|
"@babel/cli": "^7.0.0",
|
||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.0.0",
|
||||||
|
"@babel/plugin-proposal-export-default-from": "^7.0.0",
|
||||||
"@babel/plugin-proposal-function-bind": "^7.0.0",
|
"@babel/plugin-proposal-function-bind": "^7.0.0",
|
||||||
"babel-core": "^7.0.0-0",
|
"babel-core": "^7.0.0-0",
|
||||||
"babel-eslint": "^8.2.2",
|
"babel-eslint": "^8.2.2",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { dasherize } from '..';
|
const { dasherize } = require('..');
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
@ -293,6 +293,13 @@
|
|||||||
"@babel/helper-replace-supers" "^7.0.0"
|
"@babel/helper-replace-supers" "^7.0.0"
|
||||||
"@babel/plugin-syntax-class-properties" "^7.0.0"
|
"@babel/plugin-syntax-class-properties" "^7.0.0"
|
||||||
|
|
||||||
|
"@babel/plugin-proposal-export-default-from@^7.0.0":
|
||||||
|
version "7.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-default-from/-/plugin-proposal-export-default-from-7.0.0.tgz#a057bbfd4649facfe39f33a537e18554bdd2b5da"
|
||||||
|
dependencies:
|
||||||
|
"@babel/helper-plugin-utils" "^7.0.0"
|
||||||
|
"@babel/plugin-syntax-export-default-from" "^7.0.0"
|
||||||
|
|
||||||
"@babel/plugin-proposal-function-bind@^7.0.0":
|
"@babel/plugin-proposal-function-bind@^7.0.0":
|
||||||
version "7.0.0"
|
version "7.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-function-bind/-/plugin-proposal-function-bind-7.0.0.tgz#030bb3dd7affb5a0df8326cdd3e9f6776e95a225"
|
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-function-bind/-/plugin-proposal-function-bind-7.0.0.tgz#030bb3dd7affb5a0df8326cdd3e9f6776e95a225"
|
||||||
@ -347,6 +354,12 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/helper-plugin-utils" "^7.0.0"
|
"@babel/helper-plugin-utils" "^7.0.0"
|
||||||
|
|
||||||
|
"@babel/plugin-syntax-export-default-from@^7.0.0":
|
||||||
|
version "7.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-default-from/-/plugin-syntax-export-default-from-7.0.0.tgz#084b639bce3d42f3c5bf3f68ccb42220bb2d729d"
|
||||||
|
dependencies:
|
||||||
|
"@babel/helper-plugin-utils" "^7.0.0"
|
||||||
|
|
||||||
"@babel/plugin-syntax-function-bind@^7.0.0":
|
"@babel/plugin-syntax-function-bind@^7.0.0":
|
||||||
version "7.0.0"
|
version "7.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-function-bind/-/plugin-syntax-function-bind-7.0.0.tgz#04ad5fac3f68460ef028b1d92abc09781f2e7478"
|
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-function-bind/-/plugin-syntax-function-bind-7.0.0.tgz#04ad5fac3f68460ef028b1d92abc09781f2e7478"
|
||||||
|
Reference in New Issue
Block a user