next.config.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. register: true,
  16. skipWaiting: true,
  17. disableDevLogs: true,
  18. publicExcludes: ['!img/platformlogos/**/*', '!styles/admin/**/*'],
  19. buildExcludes: [/chunks\/pages\/admin.*/, '!**/admin/**/*'],
  20. sourcemap: process.env.NODE_ENV === 'development',
  21. disable: process.env.NODE_ENV === 'development',
  22. });
  23. module.exports = withPWA(
  24. withBundleAnalyzer(
  25. withLess({
  26. productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true',
  27. trailingSlash: true,
  28. reactStrictMode: true,
  29. images: {
  30. unoptimized: true,
  31. },
  32. swcMinify: true,
  33. webpack(config) {
  34. config.module.rules.push({
  35. test: /\.svg$/i,
  36. issuer: /\.[jt]sx?$/,
  37. use: ['@svgr/webpack'],
  38. });
  39. return config;
  40. },
  41. async rewrites() {
  42. return [
  43. {
  44. source: '/api/:path*',
  45. destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS.
  46. },
  47. {
  48. source: '/hls/:path*',
  49. destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS.
  50. },
  51. {
  52. source: '/img/:path*',
  53. destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS.
  54. },
  55. {
  56. source: '/logo',
  57. destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS.
  58. },
  59. {
  60. source: '/thumbnail.jpg',
  61. destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS.
  62. },
  63. {
  64. source: '/customjavascript',
  65. destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS.
  66. },
  67. ];
  68. },
  69. pageExtensions: ['tsx'],
  70. }),
  71. ),
  72. );