Last active
September 20, 2019 20:45
-
-
Save abedzantout/fe8aab9db7653e44d5dac16383343bf0 to your computer and use it in GitHub Desktop.
Next Config Final
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
| // next.config.js | |
| const withCSS = require('@zeit/next-css'); | |
| const path = require('path'); | |
| const Dotenv = require('dotenv-webpack'); | |
| const { generateAllArticles } = require('./utils/helpers'); | |
| const next_config = { | |
| webpack: config => { | |
| config.plugins = config.plugins || []; | |
| config.plugins = [ | |
| ...config.plugins, | |
| // Read the .env file | |
| new Dotenv({ | |
| path: path.join(__dirname, '.env'), | |
| systemvars: true | |
| }) | |
| ]; | |
| return config; | |
| }, | |
| // New exportPathMap function added | |
| // This will allow us to export all available blog posts when building and exporting our website | |
| exportPathMap: async () => { | |
| const articles = await generateAllArticles(); | |
| const insights = articles.reduce( | |
| (pages, entry) => | |
| Object.assign({}, pages, { | |
| [`/post/${entry.slug}`]: { | |
| page: '/post', | |
| query: { post: entry.slug } | |
| } | |
| }), | |
| {} | |
| ); | |
| const pages = { | |
| '/': { page: '/' }, | |
| '/post': { page: '/post' } | |
| }; | |
| return Object.assign({}, pages, insights); | |
| } | |
| }; | |
| module.exports = withCSS({ ...next_config }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment