forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
76 lines (69 loc) · 1.85 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
const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { findPages } = require('./docs/src/modules/utils/find');
const ENABLE_STATS = false;
process.env.MATERIAL_UI_VERSION = pkg.version;
module.exports = {
webpack: config => {
const plugins = config.plugins.concat([
new webpack.DefinePlugin({
'process.env': {
MATERIAL_UI_VERSION: JSON.stringify(process.env.MATERIAL_UI_VERSION),
},
}),
]);
if (ENABLE_STATS) {
plugins.push(
// For all options see https://github.com/th0r/webpack-bundle-analyzer#as-plugin
new BundleAnalyzerPlugin({
analyzerMode: 'server',
generateStatsFile: true,
// Will be available at `.next/stats.json`
statsFilename: 'stats.json',
})
);
}
return Object.assign({}, config, {
plugins,
externals: Object.assign({}, config.externals, {
fs: 'fs',
}),
module: Object.assign({}, config.module, {
rules: config.module.rules.concat([
{
test: /\.(css|md)$/,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]',
},
},
{
test: /\.(css|md)$/,
loader: 'raw-loader',
},
]),
}),
});
},
webpackDevMiddleware: config => config,
poweredByHeader: false,
exportPathMap: () => {
const pages = findPages();
const map = {
'/': { page: '/' },
}
pages.forEach(lvl0Page => {
if (!lvl0Page.children) {
return
}
lvl0Page.children.forEach(lvl1Page => {
map[lvl1Page.pathname] = {
page: lvl1Page.pathname,
}
})
})
return map;
},
};