next.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.wasm",
  27. to: "static/chunks/[name][ext]",
  28. },
  29. {
  30. from: "./node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm",
  31. to: "static/chunks/[name][ext]",
  32. },
  33. {
  34. from: "node_modules/@ricky0123/vad-web/dist/vad.worklet.bundle.min.js",
  35. to: "static/chunks/[name][ext]",
  36. },
  37. {
  38. from: "node_modules/@ricky0123/vad-web/dist/*.onnx",
  39. to: "static/chunks/[name][ext]",
  40. },
  41. ],
  42. })
  43. );
  44. config.plugins.push(
  45. new webpack.DefinePlugin({
  46. 'process.env.NEXT_PUBLIC_CONFIG_BUILD_ID': JSON.stringify(buildId)
  47. })
  48. );
  49. return config;
  50. },
  51. }
  52. module.exports = withPWA(nextConfig);