diff --git a/next.config.js b/next.config.js index 88d2f76..1ce5187 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,57 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const SentryWebpackPlugin = require('@sentry/webpack-plugin') +const { + NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN, + SENTRY_ORG, + SENTRY_PROJECT, + SENTRY_AUTH_TOKEN, + SENTRY_RELEASE, + SOURCE_COMMIT, + SOURCE_BRANCH, + NODE_ENV +} = process.env + +const VERSION = require('./package.json').version +const basePath = '' + module.exports = { - images: { - domains: ['cdn.discordapp.com'] + env: { + NEXT_PUBLIC_RELEASE_VERSION: VERSION }, - experimental: { scrollRestoration: true } + webpack: (config, options) => { + if(!options.isServer) { + config.resolve.alias['@sentry/node'] = '@sentry/browser' + } + config.plugins.push( + new options.webpack.DefinePlugin({ + 'process.env.NEXT_IS_SERVER': JSON.stringify( + options.isServer.toString() + ), + }) + ) + + if ( + SENTRY_DSN && + SENTRY_ORG && + SENTRY_PROJECT && + SENTRY_AUTH_TOKEN && + SENTRY_RELEASE && + VERSION && + NODE_ENV === 'production' + ) { + config.plugins.push( + new SentryWebpackPlugin({ + include: '.next', + ignore: ['node_modules'], + stripPrefix: ['webpack://_N_E/'], + urlPrefix: `~${basePath}/_next`, + release: `${SENTRY_RELEASE === 'stable' ? VERSION : SOURCE_COMMIT || VERSION}-${SOURCE_BRANCH || SENTRY_RELEASE}`, + }) + ) + } + return config + }, + experimental: { scrollRestoration: true }, + + basePath } \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index 117657f..36bef4d 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -3,6 +3,7 @@ import type { AppProps } from 'next/app' import { ThemeProvider } from 'next-themes' import dynamic from 'next/dynamic' import { useEffect, useState } from 'react' +import { init } from '@utils/Sentry' const Footer = dynamic(() => import('@components/Footer')) const Navbar = dynamic(() => import('@components/Navbar')) @@ -17,7 +18,9 @@ import '../app.css' import '@fortawesome/fontawesome-free/css/all.css' import '../github-markdown.css' -export default function App({ Component, pageProps }: AppProps): JSX.Element { +init() + +export default function App({ Component, pageProps, err }: KoreanbotsProps): JSX.Element { const [ betaKey, setBetaKey ] = useState('') const [ theme, setDefaultTheme ] = useState(undefined) let systemColor:string @@ -63,7 +66,7 @@ export default function App({ Component, pageProps }: AppProps): JSX.Element {
{ - process.env.NEXT_PUBLIC_TESTER_KEY === Crypto.createHmac('sha256', betaKey ?? '').digest('hex') ? :
+ process.env.NEXT_PUBLIC_TESTER_KEY === Crypto.createHmac('sha256', betaKey ?? '').digest('hex') ? :

주어진 테스터키를 입력해주세요.


{ localStorage.setItem('betaKey', e.target.value); setBetaKey(e.target.value) }} />
@@ -72,4 +75,8 @@ export default function App({ Component, pageProps }: AppProps): JSX.Element {