2019-03-04 18:02:45 +01:00
|
|
|
module.exports = (pluginOptions = {}) => (nextConfig = {}) => {
|
|
|
|
const extension = pluginOptions.extension || /\.mdx$/
|
|
|
|
|
|
|
|
return Object.assign({}, nextConfig, {
|
2019-11-11 04:24:53 +01:00
|
|
|
webpack(config, options) {
|
2019-03-04 18:02:45 +01:00
|
|
|
config.module.rules.push({
|
|
|
|
test: extension,
|
|
|
|
use: [
|
|
|
|
options.defaultLoaders.babel,
|
|
|
|
{
|
|
|
|
loader: '@mdx-js/loader',
|
2019-11-11 04:24:53 +01:00
|
|
|
options: pluginOptions.options,
|
|
|
|
},
|
|
|
|
],
|
2019-03-04 18:02:45 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
if (typeof nextConfig.webpack === 'function') {
|
|
|
|
return nextConfig.webpack(config, options)
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
2019-11-11 04:24:53 +01:00
|
|
|
},
|
2019-03-04 18:02:45 +01:00
|
|
|
})
|
|
|
|
}
|