Skip to content

Instantly share code, notes, and snippets.

@pkellner
Created November 11, 2018 21:43
Show Gist options
  • Save pkellner/a2362c22cfd214588b7a4450f59a0a6a to your computer and use it in GitHub Desktop.
Save pkellner/a2362c22cfd214588b7a4450f59a0a6a to your computer and use it in GitHub Desktop.
Sample next.config.js for Next.js that includes environment variables, and other plugins (CSS and Image)
const withCSS = require("@zeit/next-css");
require('dotenv').config()
const path = require('path')
const Dotenv = require('dotenv-webpack')
const withImages = require('next-images')
module.exports = withCSS(withImages({
inlineImageLimit: 16384,
webpack(config, options) {
config.plugins = config.plugins || [];
config.plugins = [
...config.plugins,
// Read the .env file
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true
})
];
return config
}
}));
@pkellner
Copy link
Author

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment