1
1
mirror of https://github.com/primer/css.git synced 2025-01-08 07:23:03 +03:00
css/lib/config.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-04-03 08:59:01 +03:00
/* eslint-disable no-console */
2019-04-03 18:30:28 +03:00
const {NODE_ENV, NOW_URL} = process.env
2019-04-03 08:59:01 +03:00
module.exports = (nextConfig = {}) => {
const {assetPrefix = NOW_URL || ''} = nextConfig
return Object.assign({}, nextConfig, {
assetPrefix,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
2019-04-03 18:30:28 +03:00
publicRuntimeConfig: Object.assign(
{
assetPrefix,
production: NODE_ENV === 'production'
},
nextConfig.publicRuntimeConfig
),
2019-04-03 08:59:01 +03:00
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'), require.resolve('./search-loader')]
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}