104b8d4732
**What's the problem this PR addresses?** `@next/mdx` adds the webpack loader `@mdx-js/loader` without resolving it to an absolute path Depends on https://github.com/vercel/next.js/pull/17606 **How did you fix it?** `require.resolve` the webpack loader before adding it
24 lines
599 B
JavaScript
24 lines
599 B
JavaScript
module.exports = (pluginOptions = {}) => (nextConfig = {}) => {
|
|
const extension = pluginOptions.extension || /\.mdx$/
|
|
|
|
return Object.assign({}, nextConfig, {
|
|
webpack(config, options) {
|
|
config.module.rules.push({
|
|
test: extension,
|
|
use: [
|
|
options.defaultLoaders.babel,
|
|
{
|
|
loader: require.resolve('@mdx-js/loader'),
|
|
options: pluginOptions.options,
|
|
},
|
|
],
|
|
})
|
|
|
|
if (typeof nextConfig.webpack === 'function') {
|
|
return nextConfig.webpack(config, options)
|
|
}
|
|
|
|
return config
|
|
},
|
|
})
|
|
}
|