next.config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const withMDX = require('@next/mdx')({
  2. extension: /\.mdx?$/,
  3. options: {
  4. // Disable MDX createElement hack
  5. // because we don't need rendering custom elements
  6. jsx: true,
  7. },
  8. });
  9. /** @type {import('next').NextConfig} */
  10. module.exports = withMDX({
  11. basePath: '/ya-webadb/apps/demo/out', //process.env.BASE_PATH || '', //'/ya-webadb/apps/demo/out', //process.env.BASE_PATH || '',
  12. pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
  13. reactStrictMode: false,
  14. productionBrowserSourceMaps: true,
  15. staticPageGenerationTimeout: 2000,
  16. experimental: {
  17. // Workaround https://github.com/vercel/next.js/issues/33914
  18. esmExternals: 'loose',
  19. },
  20. publicRuntimeConfig: {
  21. basePath: '/ya-webadb/apps/demo/out', // process.env.BASE_PATH || '',// '/ya-webadb/apps/demo/out' // process.env.BASE_PATH || '',
  22. },
  23. webpack(config, options) {
  24. config.module.rules.push({
  25. resourceQuery: /url/,
  26. type: "asset/resource",
  27. generator: {
  28. filename: "static/chunks/[name].[hash][ext]",
  29. },
  30. });
  31. config.module.rules.push({
  32. test: /.*\.m?js$/,
  33. // disable these modules because they generate a lot of warnings about
  34. // non existing source maps
  35. // we cannot filter these warnings via config.stats.warningsFilter
  36. // because Next.js doesn't allow it
  37. // https://github.com/vercel/next.js/pull/7550#issuecomment-512861158
  38. // https://github.com/vercel/next.js/issues/12861
  39. exclude: [
  40. /next/,
  41. ],
  42. use: ['source-map-loader'],
  43. //enforce: 'pre',
  44. });
  45. config.module.rules.push(
  46. {
  47. enforce: 'pre',
  48. test: /\.html$/,
  49. loader: 'html-loader',
  50. }
  51. );
  52. // config.experiments.topLevelAwait = true;
  53. return config;
  54. },
  55. async headers() {
  56. return [
  57. {
  58. source: '/:path*',
  59. headers: [
  60. {
  61. key: 'Cross-Origin-Opener-Policy',
  62. value: 'same-origin',
  63. },
  64. {
  65. key: 'Cross-Origin-Embedder-Policy',
  66. value: 'require-corp',
  67. }
  68. ]
  69. }
  70. ]
  71. }
  72. });