This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
77 lines (67 loc) · 2.28 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const path = require("path");
const nextBundleAnalyzer = require("@next/bundle-analyzer");
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const nextSourceMaps = require("@zeit/next-source-maps");
// Environment Variables
const {
GITHUB_RELEASE_TAG_NAME,
GITHUB_REPOSITORY,
GITHUB_SHA,
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
NEXT_PUBLIC_VERCEL_ENV: VERCEL_ENV,
SENTRY_AUTH_TOKEN,
SENTRY_ORG,
SENTRY_PROJECT,
} = process.env;
process.env.SENTRY_DSN = SENTRY_DSN;
//
const withBundleAnalyzer = nextBundleAnalyzer({
enabled: !!process.env.ANALYZE,
});
const withSourceMaps = nextSourceMaps({
devtool: "hidden-source-map",
});
module.exports = withBundleAnalyzer(
withSourceMaps({
poweredByHeader: false,
target: "serverless",
webpack: (config, options) => {
config.resolve.alias["~"] = path.resolve(__dirname, "src");
if (!options.isServer) {
config.resolve.alias["@sentry/node"] = "@sentry/browser";
}
if (
GITHUB_REPOSITORY &&
GITHUB_SHA &&
SENTRY_AUTH_TOKEN &&
SENTRY_DSN &&
SENTRY_ORG &&
SENTRY_PROJECT &&
VERCEL_ENV
) {
config.plugins.push(
new SentryWebpackPlugin({
deploy: {
env: VERCEL_ENV,
},
ignore: ["node_modules"],
include: ".next",
release: GITHUB_RELEASE_TAG_NAME || GITHUB_SHA,
setCommits: {
// Sentry にある Vercel の Integration で追加される SENTRY_AUTH_TOKEN だとスコープの設定でデプロイに失敗してしまう
// error: API request failed
// caused by: sentry reported an error: You do not have permission to perform this action. (http status: 403)
// https://sentry.io/settings/account/api/auth-tokens/ で認証トークンを作成、Vercel に登録する必要がある
// `event:read` と `event:write`、`org:integrations`、`org:read`、`org:write`、`project:read`、`project:releases`、`project:write` を追加した
commit: GITHUB_SHA,
repo: GITHUB_REPOSITORY,
},
stripPrefix: ["webpack://_N_E/"],
urlPrefix: `~/_next`,
})
);
}
return config;
},
})
);