Skip to content

Commit 71b0348

Browse files
alexandernanberggaearon
authored andcommitted
Upgrade to Gatsby v2 (reactjs#1104)
* Upgrade to Gatsby v2 * Remove unnecessary polyfills since gatsby already provides them * Move global styles to gatsby-browser * Add fb comment and convert to cjs * Revert to use pageQuery again * Add back html.js * Update dependencies * Move TitleAndMetaTags * Replace glamor/reset with normalize.css which fixes style order in prod * Prettier formatting * Remove unused types * Remove old layout * Fix versions link * Update deps * Update deps * Remove hack since it's no longer needed * Update dependencies * Fix build error * Fix prettier config resolution * Update gatsby * Remove custom onCreatePage logic * Update dependencies * Fix build * Update dependencies * prettier formatting * update dependencies * add custom babel config for flow * upgrade dependencies * update dependencies * use stable gatsby release
1 parent 12f003c commit 71b0348

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4277
-4191
lines changed

.babelrc

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
11
{
2-
"presets": ['react', 'es2015', 'stage-1'],
3-
"plugins": ['add-module-exports']
4-
}
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"loose": true,
7+
"modules": false,
8+
"useBuiltIns": "usage",
9+
"shippedProposals": true,
10+
"targets": {
11+
"browsers": [">0.25%", "not dead"],
12+
}
13+
}
14+
],
15+
[
16+
"@babel/preset-react",
17+
{
18+
"useBuiltIns": true,
19+
"pragma": "React.createElement",
20+
}
21+
],
22+
"@babel/flow"
23+
],
24+
"plugins": [
25+
[
26+
"@babel/plugin-proposal-class-properties",
27+
{
28+
"loose": true
29+
}
30+
],
31+
"@babel/plugin-syntax-dynamic-import",
32+
"babel-plugin-macros",
33+
[
34+
"@babel/plugin-transform-runtime",
35+
{
36+
"helpers": true,
37+
"regenerator": true
38+
}
39+
]
40+
]
41+
}
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
declare module 'gatsby-link' {
1+
declare module 'gatsby' {
22
declare module.exports: any;
33
}

flow-typed/glamor.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ declare module 'glamor/react' {
1515
propMerge: Function,
1616
};
1717
}
18-
19-
declare module 'glamor/reset' {
20-
declare module.exports: any;
21-
}

flow-typed/graphql.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

flow-typed/polyfills.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

gatsby-browser.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* @emails react-core
5+
*/
6+
7+
'use strict';
8+
9+
// Import global styles
10+
require('normalize.css');
11+
require('./src/css/reset.css');
12+
require('./src/prism-styles');
13+
require('./src/css/algolia.css');
14+
15+
// A stub function is needed because gatsby won't load this file otherwise
16+
// (https://github.com/gatsbyjs/gatsby/issues/6759)
17+
exports.onClientEntry = () => {};

gatsby-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ module.exports = {
2323
'gatsby-transformer-versions-yaml',
2424
'gatsby-plugin-netlify',
2525
'gatsby-plugin-glamor',
26-
'gatsby-plugin-react-next',
2726
'gatsby-plugin-twitter',
2827
{
2928
resolve: 'gatsby-plugin-nprogress',
@@ -134,7 +133,7 @@ module.exports = {
134133
{
135134
allMarkdownRemark
136135
(limit: 10,
137-
filter: {id: {regex: "/blog/"}},
136+
filter: {fileAbsolutePath: {regex: "/blog/"}},
138137
sort: {fields: [fields___date],
139138
order: DESC}) {
140139
edges {

gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
'use strict';
88

9-
exports.modifyWebpackConfig = require('./gatsby/modifyWebpackConfig');
9+
exports.onCreateWebpackConfig = require('./gatsby/onCreateWebpackConfig');
1010
exports.createPages = require('./gatsby/createPages');
1111
exports.onCreateNode = require('./gatsby/onCreateNode');
1212
exports.onCreatePage = require('./gatsby/onCreatePage');

gatsby/createPages.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
const {resolve} = require('path');
1010

11-
module.exports = async ({graphql, boundActionCreators}) => {
12-
const {createPage, createRedirect} = boundActionCreators;
11+
module.exports = async ({graphql, actions}) => {
12+
const {createPage, createRedirect} = actions;
1313

1414
// Used to detect and prevent duplicate redirects
1515
const redirectToSlugMap = {};
@@ -129,7 +129,7 @@ module.exports = async ({graphql, boundActionCreators}) => {
129129
{
130130
allMarkdownRemark(
131131
limit: 1
132-
filter: {id: {regex: "/blog/"}}
132+
filter: {fileAbsolutePath: {regex: "/blog/"}}
133133
sort: {fields: [fields___date], order: DESC}
134134
) {
135135
edges {
@@ -143,6 +143,7 @@ module.exports = async ({graphql, boundActionCreators}) => {
143143
}
144144
`,
145145
);
146+
146147
const newestBlogNode = newestBlogEntry.data.allMarkdownRemark.edges[0].node;
147148

148149
// Blog landing page should always show the most recent blog entry.
@@ -151,4 +152,4 @@ module.exports = async ({graphql, boundActionCreators}) => {
151152
redirectInBrowser: true,
152153
toPath: newestBlogNode.fields.slug,
153154
});
154-
};
155+
};

0 commit comments

Comments
 (0)