next.config.js 1.5 KB

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