-
Notifications
You must be signed in to change notification settings - Fork 27.5k
/
Copy pathindex.js
41 lines (37 loc) · 1.14 KB
/
index.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
module.exports =
(pluginOptions = {}) =>
(nextConfig = {}) => {
const extension = pluginOptions.extension || /\.mdx$/
const loader = nextConfig?.experimental?.mdxRs
? {
loader: require.resolve('./mdx-rs-loader'),
options: {
providerImportSource: 'next-mdx-import-source-file',
...pluginOptions.options,
},
}
: {
loader: require.resolve('@mdx-js/loader'),
options: {
providerImportSource: 'next-mdx-import-source-file',
...pluginOptions.options,
},
}
return Object.assign({}, nextConfig, {
webpack(config, options) {
config.resolve.alias['next-mdx-import-source-file'] = [
'private-next-root-dir/src/mdx-components',
'private-next-root-dir/mdx-components',
'@mdx-js/react',
]
config.module.rules.push({
test: extension,
use: [options.defaultLoaders.babel, loader],
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
},
})
}