-
-
Save shanvl/2d27b99583c8612866292afe41f20482 to your computer and use it in GitHub Desktop.
Next.js configuration for dotenv and custom servers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
require('dotenv').config({ | |
path: process.env.NODE_ENV === 'production' ? '.env.production' : '.env' | |
}); | |
module.exports = { | |
webpack: config => { | |
const env = Object.keys(process.env).reduce((acc, curr) => { | |
acc[`process.env.${curr}`] = JSON.stringify(process.env[curr]); | |
return acc; | |
}, {}); | |
config.plugins.push(new webpack.DefinePlugin(env)); | |
return config; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment