next.config.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const CopyPlugin = require("copy-webpack-plugin");
  2. const withPWA = require('@ducanh2912/next-pwa').default({
  3. dest: 'public',
  4. });
  5. /** @type {import('next').NextConfig} */
  6. const nextConfig = {
  7. reactStrictMode: false,
  8. assetPrefix: process.env.BASE_PATH || "",
  9. basePath: process.env.BASE_PATH || "",
  10. trailingSlash: true,
  11. publicRuntimeConfig: {
  12. root: process.env.BASE_PATH || "",
  13. },
  14. optimizeFonts: false,
  15. webpack: (config, { webpack, buildId }) => {
  16. // See https://webpack.js.org/configuration/resolve/#resolvealias
  17. config.resolve.alias = {
  18. ...config.resolve.alias,
  19. "sharp$": false,
  20. "onnxruntime-node$": false,
  21. }
  22. config.plugins.push(
  23. new CopyPlugin({
  24. patterns: [
  25. {
  26. from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm",
  27. to: "static/chunks/[name][ext]",
  28. },
  29. {
  30. from: "./node_modules/onnxruntime-web/dist/ort-wasm-threaded.wasm",
  31. to: "static/chunks/[name][ext]",
  32. },
  33. {
  34. from: "./node_modules/onnxruntime-web/dist/ort-wasm.wasm",
  35. to: "static/chunks/[name][ext]",
  36. },
  37. {
  38. from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm",
  39. to: "static/chunks/[name][ext]",
  40. },
  41. {
  42. from: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
  43. to: "static/chunks/[name][ext]",
  44. },
  45. {
  46. from: "node_modules/@ricky0123/vad-web/dist/*.onnx",
  47. to: "static/chunks/[name][ext]",
  48. },
  49. ],
  50. })
  51. );
  52. config.plugins.push(
  53. new webpack.DefinePlugin({
  54. 'process.env.NEXT_PUBLIC_CONFIG_BUILD_ID': JSON.stringify(buildId)
  55. })
  56. );
  57. return config;
  58. },
  59. }
  60. module.exports = withPWA(nextConfig);