Skip to content

Instantly share code, notes, and snippets.

@markerikson
Created November 2, 2021 20:12
Show Gist options
  • Save markerikson/d45d4a27fd119494b386b0e40826bd54 to your computer and use it in GitHub Desktop.
Save markerikson/d45d4a27fd119494b386b0e40826bd54 to your computer and use it in GitHub Desktop.

Revisions

  1. markerikson created this gist Nov 2, 2021.
    51 changes: 51 additions & 0 deletions next.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    // omit imports and stuff

    // Using Next 11.1

    module.exports = withPlugins(
    [
    withBundleAnalyzer({
    enabled: process.env.ANALYZE === 'true'
    })
    ],
    {
    // Expose EMR app config values to all server-side Next code
    serverRuntimeConfig: config,
    // Generate sourcemaps for prod builds
    productionBrowserSourceMaps: true,
    // Use Webpack 5 instead of WP4
    webpack5: true,
    eslint: {
    // Don't run additional ESLint checks during builds - we do that ourselves
    ignoreDuringBuilds: true
    },
    webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
    const resolvedBaseUrl = path.resolve(config.context, '..');
    // This extra config allows to use paths defined in tsconfig
    // @link https://github.com/vercel/next.js/pull/13542
    Object.assign(config.resolve.alias, hq.get('webpack'));

    config.module.rules = [
    ...config.module.rules,
    {
    test: /\.(tsx|ts|js|mjs|jsx)$/,
    include: [resolvedBaseUrl],
    use: defaultLoaders.babel,
    exclude: excludePath => {
    return /node_modules/.test(excludePath);
    }
    }
    ];

    config.plugins.push(
    new CircularDependencyPlugin({
    failOnError: true,
    exclude: /node_modules|graphQL/i,
    cwd: process.cwd()
    })
    );

    return config;
    }
    }
    );