forked from coderplex-org/coderplex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
67 lines (66 loc) · 1.91 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
const { ANALYZE } = process.env;
const { laravelSyllabus, listOfSubjects, reactSyllabus } = require('./utils/mock-data');
module.exports = {
webpack: (config, { dev }) => {
/* Enable only in Production */
if (!dev) {
// Preact
// console.log('> Using Preact instead of React');
// config.resolve.alias = {
// react: 'preact-compat/dist/preact-compat',
// 'react-dom': 'preact-compat/dist/preact-compat',
// 'react-emotion': 'preact-emotion',
// };
if (ANALYZE) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
})
);
}
}
return config;
},
exportPathMap() {
const routes = {
'/': { page: '/' },
'/events': { page: '/events' },
'/learn': { page: '/learn' },
'/space': { page: '/space' },
'/join': { page: '/join' },
'/feedback': { page: '/feedback' },
'/terms': { page: '/terms' },
'/privacy': { page: '/privacy' },
};
const getSubject = subjectId => {
switch (subjectId) {
case 'laravel':
return laravelSyllabus;
case 'reactjs':
return reactSyllabus;
default:
return [];
}
};
for (const subject of listOfSubjects) {
for (const unit of getSubject(subject.subjectId)) {
const { chapters } = unit;
for (const chapter of chapters) {
const chapterSlug = chapter.name.replace(/\s/gi, '-');
const route = `/learn/${subject.subjectId}/${chapterSlug}`;
routes[route] = {
page: '/learn/subject',
query: {
subject: subject.subjectId,
chapter: chapterSlug,
},
};
}
}
}
return routes;
},
};