Adopt Gatsby (#2906)
While Next.js can handle static sites, we've had a few issues with it, notably a performance hit at runtime and some bugginess around routing and SSR. Gatsby being fully intended for high-performance static sites makes it a great technical fit for the Shields frontend. The `createPages()` API should be a really nice way to add a page for each service family, for example. This migrates the frontend from Next.js to Gatsby. Gatsby is a powerful tool, which has a bit of downside as there's a lot to dig through. Overall I found configuration easier than Next.js. There are a lot of plugins and for the most part they worked out of the box. The documentation is good. Links are cleaner now: there is no #. This will break old links though perhaps we could add some redirection to help with that. The only one I’m really concerned about `/#/endpoint`. I’m not sure if folks are deep-linking to the category pages. There are a lot of enhancements we could add, in order to speed up the site even more. In particular we could think about inlining the SVGs rather than making separate requests for each one. While Gatsby recommends GraphQL, it's not required. To keep things simple and reduce the learning curve, I did not use it here. Close #1943 Fix #2837 Fix #2616
This commit is contained in:
49
package.json
49
package.json
@@ -82,7 +82,7 @@
|
||||
"test:js:server": "echo \"Deprecated; run `npm run test:core` instead.\" && npm run test:core",
|
||||
"test:js:frontend": "echo \"Deprecated; run `npm run test:frontend` instead.\" && npm run test:frontend",
|
||||
"test:js:package": "echo \"Deprecated; run `npm run test:package` instead.\" && npm run test:package",
|
||||
"test:frontend": "cross-env BABEL_ENV=test mocha --opts mocha.opts --require @babel/polyfill --require @babel/register --require mocha-yaml-loader \"frontend/**/*.spec.js\"",
|
||||
"test:frontend": "cross-env NODE_ENV=test mocha --opts mocha.opts --require @babel/polyfill --require @babel/register --require mocha-yaml-loader --require frontend/mocha-ignore-pngs \"frontend/**/*.spec.js\"",
|
||||
"test:core": "cross-env NODE_CONFIG_ENV=test mocha --opts mocha.opts \"core/**/*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"",
|
||||
"test:package": "mocha --opts mocha.opts \"gh-badges/**/*.spec.js\"",
|
||||
"test:entrypoint": "cross-env NODE_CONFIG_ENV=test mocha --opts mocha.opts entrypoint.spec.js",
|
||||
@@ -99,13 +99,12 @@
|
||||
"prebuild": "run-s --silent depcheck",
|
||||
"features": "node scripts/export-supported-features-cli.js > supported-features.json",
|
||||
"defs": "node scripts/export-service-definitions-cli.js > service-definitions.yml",
|
||||
"build": "run-s --silent defs features && cross-env BABEL_ENV=dev-prod next build && cross-env BABEL_ENV=dev-prod next export -o build/",
|
||||
"build": "run-s defs features && gatsby build",
|
||||
"heroku-postbuild": "run-s --silent build",
|
||||
"analyze": "cross-env ANALYZE=true BASE_URL=https://img.shields.io npm run build",
|
||||
"start:server": "cross-env NODE_CONFIG_ENV=development node server 8080",
|
||||
"now-start": "node server",
|
||||
"prestart": "run-s --silent depcheck defs features",
|
||||
"start": "concurrently --names server,frontend \"npm run start:server\" \"cross-env BASE_URL=http://localhost:8080 BABEL_ENV=dev-prod next dev\"",
|
||||
"start": "concurrently --names server,frontend \"npm run start:server\" \"cross-env GATSBY_BASE_URL=http://localhost:8080 gatsby develop --port 3000\"",
|
||||
"refactoring-report": "node scripts/refactoring-cli.js",
|
||||
"badge": "cross-env NODE_CONFIG_ENV=test TRACE_SERVICES=true node scripts/badge-cli.js"
|
||||
},
|
||||
@@ -125,7 +124,9 @@
|
||||
"@babel/register": "7.0.0",
|
||||
"@mapbox/react-click-to-select": "^2.2.0",
|
||||
"babel-eslint": "^10.0.0",
|
||||
"babel-plugin-inline-react-svg": "^1.0.1",
|
||||
"babel-plugin-istanbul": "^5.1.0",
|
||||
"babel-preset-gatsby": "^0.1.6",
|
||||
"caller": "^1.0.1",
|
||||
"chai": "^4.1.2",
|
||||
"chai-datetime": "^1.5.0",
|
||||
@@ -155,6 +156,13 @@
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"fetch-ponyfill": "^6.0.0",
|
||||
"fs-readfile-promise": "^3.0.1",
|
||||
"gatsby": "^2.0.107",
|
||||
"gatsby-plugin-catch-links": "^2.0.10",
|
||||
"gatsby-plugin-page-creator": "^2.0.6",
|
||||
"gatsby-plugin-react-helmet": "^3.0.5",
|
||||
"gatsby-plugin-remove-trailing-slashes": "^2.0.7",
|
||||
"gatsby-plugin-styled-components": "^3.0.5",
|
||||
"gatsby-source-filesystem": "^2.0.19",
|
||||
"got": "^9.6.0",
|
||||
"humanize-string": "^1.0.2",
|
||||
"husky": "^1.3.1",
|
||||
@@ -173,7 +181,6 @@
|
||||
"mocha-env-reporter": "^3.0.0",
|
||||
"mocha-junit-reporter": "^1.18.0",
|
||||
"mocha-yaml-loader": "^1.0.3",
|
||||
"next": "^7.0.2",
|
||||
"nock": "11.0.0-beta.6",
|
||||
"node-fetch": "^2.3.0",
|
||||
"node-mocks-http": "^1.7.3",
|
||||
@@ -187,12 +194,14 @@
|
||||
"prop-types": "^15.6.0",
|
||||
"react": "^16.7.0",
|
||||
"react-dom": "^16.7.0",
|
||||
"react-error-overlay": "^5.1.2",
|
||||
"react-helmet": "^5.2.0",
|
||||
"react-modal": "^3.8.1",
|
||||
"react-pose": "^4.0.6",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-select": "^2.3.0",
|
||||
"read-all-stdin-sync": "^1.0.5",
|
||||
"redis-server": "^1.2.2",
|
||||
"require-hacker": "^3.0.1",
|
||||
"rimraf": "^2.6.3",
|
||||
"sazerac": "^0.4.2",
|
||||
"sinon": "^7.2.3",
|
||||
@@ -200,7 +209,8 @@
|
||||
"snap-shot-it": "^6.2.9",
|
||||
"styled-components": "^4.1.3",
|
||||
"tmp": "0.0.33",
|
||||
"url": "^0.11.0"
|
||||
"url": "^0.11.0",
|
||||
"walkdir": "0.0.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8",
|
||||
@@ -208,27 +218,20 @@
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-proposal-object-rest-spread"
|
||||
[
|
||||
"inline-react-svg",
|
||||
{
|
||||
"svgo": false
|
||||
}
|
||||
]
|
||||
],
|
||||
"presets": [
|
||||
"babel-preset-gatsby"
|
||||
],
|
||||
"env": {
|
||||
"dev-prod": {
|
||||
"presets": [
|
||||
"next/babel"
|
||||
]
|
||||
},
|
||||
"test": {
|
||||
"plugins": [
|
||||
"istanbul"
|
||||
],
|
||||
"presets": [
|
||||
"@babel/preset-env",
|
||||
[
|
||||
"@babel/preset-react",
|
||||
{
|
||||
"development": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user