next.config.js 1.8 KB

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