Skip to content

Instantly share code, notes, and snippets.

@markerikson
Created November 2, 2021 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markerikson/d45d4a27fd119494b386b0e40826bd54 to your computer and use it in GitHub Desktop.
Save markerikson/d45d4a27fd119494b386b0e40826bd54 to your computer and use it in GitHub Desktop.
Work app Next.js config
// 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;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment