-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
89 lines (76 loc) · 1.99 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* eslint-disable @typescript-eslint/no-var-requires */
require('dotenv').config();
const fs = require('fs');
const withPlugins = require('next-compose-plugins');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const withMDX = require('@next/mdx')({
extension: /\.(md|mdx)$/,
});
const mdxConfig = {
pageExtensions: [
'js',
'jsx',
'ts',
'tsx',
'md',
'mdx'
]
};
const withImages = require('next-images');
module.exports = withPlugins(
[
[withMDX, mdxConfig],
withImages,
],
{
// target: 'server' is necessary to export static files
target: 'server',
env: {
// this is how you get values from the '.env' files
PORT: process.env.PORT,
ROOT: __dirname,
},
exportTrailingSlash: true,
// exportPathMap: async (
// defaultPathMap,
// { dev, dir, outDir, distDir, buildId }
// ) => {
// const pathMap = {
// '/': { page: '/' },
// '/about': { page: '/about' },
// '/play': { page: '/play' },
// // '/work': { page: '/work' },
// // '/thoughts': { page: '/thoughts' },
// };
// const playFiles = await fs.readdirSync(`${__dirname}/src/content/play/posts`);
// playFiles.map((post) => {
// const id = post.slice(0, -3);
// pathMap[`/play/${id}`] = { page: '/play/[id]', query: { id: id } };
// });
// return pathMap;
// },
webpack: (config, { defaultLoaders, isServer, dev } ) => {
// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty',
module: 'empty'
};
config.module.rules.push(
{
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack'
}
]
}
);
if (config.resolve.plugins) {
config.resolve.plugins.push(new TsconfigPathsPlugin());
} else {
config.resolve.plugins = [new TsconfigPathsPlugin()];
}
return config;
},
}
);