Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@revskill10
Forked from remy/next.config.js
Created August 16, 2018 12:15
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 revskill10/da72d3c2dfa850dd9d54129574465a86 to your computer and use it in GitHub Desktop.
Save revskill10/da72d3c2dfa850dd9d54129574465a86 to your computer and use it in GitHub Desktop.
Next.js configuration for dotenv and custom servers.
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