next.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. const withLess = require('next-with-less');
  2. const withBundleAnalyzer = require('@next/bundle-analyzer')({
  3. enabled: process.env.ANALYZE === 'true',
  4. });
  5. const runtimeCaching = require('next-pwa/cache');
  6. const withPWA = require('next-pwa')({
  7. dest: 'public',
  8. runtimeCaching: [
  9. ...runtimeCaching,
  10. {
  11. urlPattern: /\.(?:ts|m3u8)$/i,
  12. handler: 'NetworkOnly',
  13. },
  14. {
  15. urlPattern: /^\/admin\/.*$/,
  16. handler: 'NetworkOnly',
  17. },
  18. {
  19. urlPattern: /^\/api\/.*$/,
  20. handler: 'NetworkOnly',
  21. },
  22. ],
  23. register: true,
  24. skipWaiting: true,
  25. disableDevLogs: true,
  26. publicExcludes: ['!img/platformlogos/**/*', '!styles/admin/**/*'],
  27. buildExcludes: [/chunks\/pages\/admin.*/, '!**/admin/**/*'],
  28. sourcemap: process.env.NODE_ENV === 'development',
  29. disable: process.env.NODE_ENV === 'development',
  30. });
  31. module.exports = withPWA(
  32. withBundleAnalyzer(
  33. withLess({
  34. productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true',
  35. trailingSlash: true,
  36. reactStrictMode: true,
  37. images: {
  38. unoptimized: true,
  39. },
  40. swcMinify: true,
  41. webpack(config) {
  42. config.module.rules.push({
  43. test: /\.svg$/i,
  44. issuer: /\.[jt]sx?$/,
  45. use: ['@svgr/webpack'],
  46. });
  47. return config;
  48. },
  49. async rewrites() {
  50. return [
  51. {
  52. source: '/api/:path*',
  53. destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS.
  54. },
  55. {
  56. source: '/hls/:path*',
  57. destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS.
  58. },
  59. {
  60. source: '/img/:path*',
  61. destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS.
  62. },
  63. {
  64. source: '/logo',
  65. destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS.
  66. },
  67. {
  68. source: '/thumbnail.jpg',
  69. destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS.
  70. },
  71. {
  72. source: '/customjavascript',
  73. destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS.
  74. },
  75. ];
  76. },
  77. pageExtensions: ['tsx'],
  78. }),
  79. ),
  80. );