next.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** @type {import('next').NextConfig} */
  2. const CopyPlugin = require("copy-webpack-plugin");
  3. const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
  4. const path = require("path");
  5. const nextConfig = {
  6. experimental: {
  7. esmExternals: "loose",
  8. },
  9. typescript: {
  10. ignoreBuildErrors: true,
  11. },
  12. env: {
  13. API_BASE_URL: process.env.API_BASE_URL,
  14. GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID,
  15. GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
  16. GET_USER_URL: process.env.GET_USER_URL,
  17. LOGIN_URL: process.env.LOGIN_URL,
  18. LOGOUT_URL: process.env.LOGOUT_URL,
  19. },
  20. trailingSlash: true,
  21. images: { unoptimized: true },
  22. skipTrailingSlashRedirect: true,
  23. webpack: (config, { isServer }) => {
  24. config.resolve.fallback = { fs: false };
  25. if (!isServer) {
  26. config.plugins.push(
  27. new CopyPlugin({
  28. patterns: [
  29. {
  30. from: path.join(
  31. __dirname,
  32. "node_modules/@oceanbase-odc/monaco-plugin-ob/worker-dist/"
  33. ),
  34. to: "static/ob-workers",
  35. },
  36. ],
  37. })
  38. );
  39. // 添加 monaco-editor-webpack-plugin 插件
  40. config.plugins.push(
  41. new MonacoWebpackPlugin({
  42. // 你可以在这里配置插件的选项,例如:
  43. languages: ["sql"],
  44. filename: "static/[name].worker.js",
  45. })
  46. );
  47. }
  48. return config;
  49. },
  50. };
  51. const withTM = require("next-transpile-modules")([
  52. "@berryv/g2-react",
  53. "@antv/g2",
  54. "react-syntax-highlighter",
  55. "@antv/g6",
  56. "@antv/graphin",
  57. "@antv/gpt-vis",
  58. ]);
  59. module.exports = withTM({
  60. ...nextConfig,
  61. });