Skip to content

Instantly share code, notes, and snippets.

@audrenbdb
Last active December 29, 2021 13:12
Show Gist options
  • Save audrenbdb/5ff3dceaf5acd0395b1777d301f72f62 to your computer and use it in GitHub Desktop.
Save audrenbdb/5ff3dceaf5acd0395b1777d301f72f62 to your computer and use it in GitHub Desktop.
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const withPlugins = require('next-compose-plugins')
// at the moment the application version refers to git commit
const revision = require('child_process')
.execSync('git rev-parse HEAD')
.toString().trim()
const nextConfig = {
// use custom webpack config in order to import modules in getServerSideProps
webpack(config) {
config.module.rules.push({
test: /\.(tsx|ts)$/,
loader: 'ts-loader' ,
exclude: /node_modules/,
// avoid error Typescript emitted no output
options: {
compilerOptions: {
noEmit: false, // https://www.typescriptlang.org/tsconfig#noEmit
},
},
})
return config
},
env: {
IS_PROD: process.env.IS_PROD,
VERSION: revision
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
experimental: {
externalDir: true,
},
async rewrites() {
return [
{
source: '/foo/:path*',
// eslint-disable-next-line no-undef
destination: `http://${process.env.APP_API}/:path*` // Proxy to Backend
},
]
},
async redirects() {
return [
{
source: '/',
destination: '/bars',
permanent: true,
},
]
}
}
module.exports = withPlugins([withBundleAnalyzer], nextConfig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment