forked from datocms/new-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
64 lines (57 loc) · 1.28 KB
/
next.config.js
File metadata and controls
64 lines (57 loc) · 1.28 KB
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
const nextEnv = require('next-env');
const dotenvLoad = require('dotenv-load');
const path = require('path');
const redirects = require('./redirects');
dotenvLoad();
const withNextEnv = nextEnv();
const svgTemplate = (
{ template },
opts,
{ imports, componentName, props, jsx },
) => {
return template.ast`${imports}
const ${componentName} = (${props}) => ${jsx};
export default ${componentName};
`;
};
module.exports = withNextEnv({
async redirects() {
return redirects.map((r) => ({ ...r, statusCode: 301 }));
},
webpack(config) {
config.resolve.modules.push(path.resolve('./'));
config.module.rules.push({
test: /\.svg$/,
issuer: {
test: /\.jsx?$/,
},
include: [path.resolve('./public/images')],
use: [
{
loader: '@svgr/webpack',
options: {
icon: false,
template: svgTemplate,
},
},
],
});
config.module.rules.push({
test: /\.svg$/,
issuer: {
test: /\.jsx?$/,
},
include: [path.resolve('./public/icons')],
use: [
{
loader: '@svgr/webpack',
options: {
icon: true,
template: svgTemplate,
},
},
],
});
return config;
},
});