1
1
mirror of https://github.com/primer/css.git synced 2024-12-18 03:31:43 +03:00
css/docs/lib/config.js

40 lines
977 B
JavaScript
Raw Normal View History

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'}
})
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
}
})
}