2018-12-04 02:54:04 +03:00
|
|
|
module.exports = (pluginOptions = {}) => (nextConfig = {}) => {
|
|
|
|
const test = pluginOptions.extension || /\.mdx?$/
|
|
|
|
|
|
|
|
return Object.assign({}, nextConfig, {
|
|
|
|
webpack(config, options) {
|
|
|
|
if (!options.defaultLoaders) {
|
|
|
|
throw new Error(
|
|
|
|
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-12-05 00:37:31 +03:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: {loader: '@svgr/webpack'}
|
|
|
|
})
|
|
|
|
|
2018-12-04 02:54:04 +03:00
|
|
|
config.module.rules.push({
|
|
|
|
test,
|
|
|
|
use: [
|
|
|
|
options.defaultLoaders.babel,
|
|
|
|
{
|
|
|
|
loader: '@mdx-js/loader',
|
|
|
|
options: pluginOptions.options
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: require.resolve('./frontmatter.js'),
|
|
|
|
options: {raw: true}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
if (typeof nextConfig.webpack === 'function') {
|
|
|
|
return nextConfig.webpack(config, options)
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|