next.config.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const CopyPlugin = require("copy-webpack-plugin");
  2. const withPWA = require("@ducanh2912/next-pwa").default({
  3. dest: "public",
  4. });
  5. const output = process.env.NEXT_OUTPUT || undefined;
  6. /** @type {import('next').NextConfig} */
  7. const nextConfig = {
  8. output,
  9. reactStrictMode: false,
  10. assetPrefix: process.env.BASE_PATH || "",
  11. basePath: process.env.BASE_PATH || "",
  12. trailingSlash: true,
  13. publicRuntimeConfig: {
  14. root: process.env.BASE_PATH || "",
  15. },
  16. optimizeFonts: false,
  17. webpack: (config, { webpack, buildId }) => {
  18. // See https://webpack.js.org/configuration/resolve/#resolvealias
  19. config.resolve.alias = {
  20. ...config.resolve.alias,
  21. sharp$: false,
  22. "onnxruntime-node$": false,
  23. };
  24. config.plugins.push(
  25. new CopyPlugin({
  26. patterns: [
  27. {
  28. from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm",
  29. to: "static/chunks/[name][ext]",
  30. },
  31. {
  32. from: "./node_modules/onnxruntime-web/dist/ort-wasm-threaded.wasm",
  33. to: "static/chunks/[name][ext]",
  34. },
  35. {
  36. from: "./node_modules/onnxruntime-web/dist/ort-wasm.wasm",
  37. to: "static/chunks/[name][ext]",
  38. },
  39. {
  40. from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm",
  41. to: "static/chunks/[name][ext]",
  42. },
  43. {
  44. from: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
  45. to: "static/chunks/[name][ext]",
  46. },
  47. {
  48. from: "node_modules/@ricky0123/vad-web/dist/*.onnx",
  49. to: "static/chunks/[name][ext]",
  50. },
  51. ],
  52. }),
  53. );
  54. config.plugins.push(
  55. new webpack.DefinePlugin({
  56. "process.env.NEXT_PUBLIC_CONFIG_BUILD_ID": JSON.stringify(buildId),
  57. }),
  58. );
  59. return config;
  60. },
  61. };
  62. module.exports = withPWA(nextConfig);
  63. // Injected content via Sentry wizard below
  64. const { withSentryConfig } = require("@sentry/nextjs");
  65. module.exports = withSentryConfig(module.exports, {
  66. // For all available options, see:
  67. // https://github.com/getsentry/sentry-webpack-plugin#options
  68. org: "heyamica",
  69. project: "chat-heyamica",
  70. // Only print logs for uploading source maps in CI
  71. silent: !process.env.CI,
  72. // For all available options, see:
  73. // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
  74. // Upload a larger set of source maps for prettier stack traces (increases build time)
  75. widenClientFileUpload: true,
  76. // Automatically annotate React components to show their full name in breadcrumbs and session replay
  77. reactComponentAnnotation: {
  78. enabled: true,
  79. },
  80. // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
  81. // This can increase your server load as well as your hosting bill.
  82. // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
  83. // side errors will fail.
  84. tunnelRoute: "/monitoring",
  85. // Hides source maps from generated client bundles
  86. hideSourceMaps: true,
  87. // Automatically tree-shake Sentry logger statements to reduce bundle size
  88. disableLogger: true,
  89. // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
  90. // See the following for more information:
  91. // https://docs.sentry.io/product/crons/
  92. // https://vercel.com/docs/cron-jobs
  93. automaticVercelMonitors: true,
  94. });