forked from apideck-io/blog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
58 lines (46 loc) · 1.3 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 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
})
];
// Here is the magic
// We push our config into the resolve.modules array
config.resolve.modules.push(path.resolve('./'))
config.resolve.alias['template'] = path.join(__dirname, 'template')
return config;
},
env: {
'CONTENTFUL_SPACE': process.env.CONTENTFUL_SPACE,
'CONTENTFUL_TOKEN': process.env.CONTENTFUL_TOKEN
},
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 });