1
1
mirror of https://github.com/primer/css.git synced 2024-12-02 07:53:06 +03:00
css/lib/config.js
2019-03-04 14:30:23 -08:00

47 lines
1.1 KiB
JavaScript

/* eslint-disable no-console */
const {NODE_ENV, NOW_URL} = process.env
module.exports = (nextConfig = {}) => {
const {assetPrefix = NOW_URL || ''} = nextConfig
let configured = false
return Object.assign({}, nextConfig, {
assetPrefix,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
publicRuntimeConfig: Object.assign(
{
assetPrefix,
production: NODE_ENV === 'production'
},
nextConfig.publicRuntimeConfig
),
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'
)
}
config.module.rules.push({
test: /\.svg$/,
use: '@svgr/webpack'
})
config.module.rules.push({
test: /\.mdx?$/,
use: [options.defaultLoaders.babel, require.resolve('./mdx-loader')]
})
configured = true
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}