-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
86 lines (81 loc) · 2.14 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
const isAppEngine = !!process.env.GAE_APPLICATION
const isProd = process.env.NODE_ENV === 'production'
const assetPrefix = isAppEngine ? '/' : (isProd ? '/docs/as/info/' : '')
const yaml = require('js-yaml')
const fs = require('fs')
module.exports = {
distDir: 'build_dir',
assetPrefix,
env: {
ASSET_PREFIX: assetPrefix,
IS_APP_ENGINE: process.env.GAE_APPLICATION ? 'true' : 'false',
},
webpack: config => {
config.devtool = 'source-map';
config.module.rules.push({
test: /\.(png|jpe?g|gif|woff|woff2|eot|ttf|svg)$/,
use: {
loader: 'file-loader',
options: {},
}
});
config.module.rules.push({ test: /\.(ya?ml)$/, loader: "js-yaml-loader" });
for (const r of config.module.rules) {
if (r.loader === 'babel-loader') {
r.options.sourceMaps = true
}
}
return config
},
exportPathMap: async function(
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
const criteria = Object.keys(
yaml.load(fs.readFileSync('./data/criteria.yaml', 'utf8'))
).reduce(
(pages, key) =>
Object.assign({}, pages, {
[`/criteria/${key}`]: {
page: `/criteria/[id]`,
query: { id: key }
}
}),
{}
)
const results = Object.keys(
yaml.load(fs.readFileSync('./data/tests.yaml', 'utf8'))
).reduce(
(pages, key) =>
Object.assign({}, pages, {
[`/results/${key}`]: {
page: `/results/[id]`,
query: { id: key }
}
}),
{}
)
const techs = Object.keys(
yaml.load(fs.readFileSync('./data/techs.yaml', 'utf8'))
).reduce(
(pages, key) =>
Object.assign({}, pages, {
[`/techs/${key}`]: {
page: `/techs/[id]`,
query: { id: key }
}
}),
{}
)
const exportMap = Object.assign({}, criteria, results, techs, {
'/': { page: '/' },
'/criteria': { page: '/criteria' },
'/techs': { page: '/techs' },
})
return exportMap
},
images: {
domains: ['waic.jp', 'mirrors.creativecommons.org'],
unoptimized: true
},
}