next.js/test/e2e/filesystem-cache/next.config.js
next.config.js53 lines1.2 KB
const enableCaching = !!process.env.ENABLE_CACHING

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  turbopack: {
    rules: {
      './app/**/page.{jsx,tsx}': {
        loaders: ['./my-timestamp-loader.js'],
      },
      './app/loader/page.tsx': {
        loaders: ['./my-loader.js'],
      },
      './pages/pages.tsx': {
        loaders: ['./my-timestamp-loader.js'],
      },
    },
  },
  experimental: {
    turbopackFileSystemCacheForBuild: enableCaching,
    turbopackFileSystemCacheForDev: enableCaching,
  },
  env: {
    NEXT_PUBLIC_CONFIG_ENV: 'hello world',
  },
  webpack(config, { dev }) {
    config.module.rules.push({
      test: /app(?:\/.*)?\/page\.[tj]sx|pages\/pages\.tsx/,
      use: ['./my-timestamp-loader.js'],
    })
    config.module.rules.push({
      test: /app\/loader(?:\/client)?\/page\.tsx/,
      use: ['./my-loader.js'],
    })
    if (enableCaching) {
      config.cache = Object.freeze({
        type: 'memory',
      })
    }
    if (dev) {
      // Make webpack consider the build as large change which makes it filesystem cache it sooner
      config.plugins.push((compiler) => {
        compiler.__extra_delay = true
      })
    }

    return config
  },
}

module.exports = nextConfig
Quest for Codev2.0.0
/
SIGN IN