Skip to content

Commit 1297264

Browse files
author
NisanthanNanthakumar
authored
feat: Remove unused code related to nginx (#2377)
## Objective We don't use nginx for redirects. Redirects are handled through: https://docs.sentry.io/contributing/pages/redirects/ So in this PR, unused code related to nginx and its' redirects should be removed. Consensus is that the Dockerfile is not necessary, so it will be also removed in this PR. ## Test Plan Check the Vercel preview build to make sure redirects did not break.
1 parent 251d98a commit 1297264

File tree

5 files changed

+2
-91
lines changed

5 files changed

+2
-91
lines changed

Dockerfile

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"gatsby-transformer-yaml": "^2.4.8",
6161
"gray-matter": "^4.0.2",
6262
"jsdom": "^16.3.0",
63-
"nginx-conf": "^1.5.0",
6463
"node-sass": "^4.14.1",
6564
"platformicons": "^3.1.0",
6665
"prismjs": "^1.20.0",

src/gatsby/config.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,7 @@ const getPlugins = () => {
184184
path: `${root}/src/data`,
185185
},
186186
},
187-
{
188-
resolve: `./src/gatsby/plugins/gatsby-redirects`,
189-
options: {
190-
inputConfigFile: `${root}/nginx.conf`,
191-
outputConfigFile: `${root}/nginx.out.conf`,
192-
},
193-
},
187+
{ resolve: `./src/gatsby/plugins/gatsby-redirects` },
194188
{
195189
resolve: `./src/gatsby/plugins/gatsby-plugin-openapi`,
196190
options: {
@@ -204,8 +198,7 @@ const getPlugins = () => {
204198
// required, function which returns a Promise resolving Swagger JSON
205199
},
206200
},
207-
// generate normal redirects so when you're running without nginx
208-
// you receive similar behavior
201+
// used to generate clident-side redirects for markdown redirect_from
209202
`gatsby-plugin-meta-redirect`,
210203
process.env.ALGOLIA_INDEX === "1" && {
211204
resolve: `gatsby-plugin-algolia`,
Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const { NginxConfFile } = require("nginx-conf");
2-
const { remove } = require("fs-extra");
31
const { resolve } = require("url");
42

53
exports.onCreatePage = ({ page, reporter, actions: { createRedirect } }) => {
@@ -16,42 +14,3 @@ exports.onCreatePage = ({ page, reporter, actions: { createRedirect } }) => {
1614
});
1715
}
1816
};
19-
20-
// based on https://github.com/gimoteco/gatsby-plugin-nginx-redirect
21-
exports.onPostBuild = async (
22-
{ store, reporter },
23-
{ inputConfigFile, outputConfigFile }
24-
) => {
25-
const { redirects } = store.getState();
26-
27-
NginxConfFile.create(inputConfigFile, async function(err, conf) {
28-
if (err) {
29-
console.error(err);
30-
return;
31-
}
32-
33-
await conf.die(inputConfigFile);
34-
await conf.flush();
35-
36-
// this assumes a partial nginx config which lives _inside_ of a server
37-
// directive
38-
redirects.forEach(redirect => {
39-
let fromPath = redirect.fromPath;
40-
if (fromPath.slice(fromPath.length - 1) !== "/") fromPath += "/";
41-
conf.nginx._add(
42-
"rewrite",
43-
`^${fromPath}?$ ${redirect.toPath} ${
44-
redirect.isPermanent ? "permanent" : "redirect"
45-
}`
46-
);
47-
});
48-
49-
await remove(outputConfigFile);
50-
await conf.live(outputConfigFile);
51-
await conf.write();
52-
53-
reporter.info(
54-
`Added ${redirects.length} redirect(s) to ${outputConfigFile}`
55-
);
56-
});
57-
};

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12669,11 +12669,6 @@ next-tick@^1.0.0:
1266912669
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb"
1267012670
integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==
1267112671

12672-
nginx-conf@^1.5.0:
12673-
version "1.5.0"
12674-
resolved "https://registry.yarnpkg.com/nginx-conf/-/nginx-conf-1.5.0.tgz#30de1a0a0a195ed906b9cfb130ed7b950cda416d"
12675-
integrity sha512-bzVqdmATU1U9dNn9T9NVoczRJArydh6rGMxg9f8gLhzsPdQkGDqD8H1EcERgeKoLH3UC9mPiDTR6eyi2uDn/kQ==
12676-
1267712672
nice-try@^1.0.4:
1267812673
version "1.0.5"
1267912674
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"

0 commit comments

Comments
 (0)