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

47 lines
1.1 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-console */
2019-02-05 02:48:06 +03:00
const {NODE_ENV, NOW_URL} = process.env
2018-12-08 01:21:39 +03:00
module.exports = (nextConfig = {}) => {
const {assetPrefix = NOW_URL || ''} = nextConfig
let configured = false
return Object.assign({}, nextConfig, {
2018-12-08 01:21:39 +03:00
assetPrefix,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
2019-02-12 00:58:10 +03:00
publicRuntimeConfig: Object.assign(
{
assetPrefix,
production: NODE_ENV === 'production'
},
nextConfig.publicRuntimeConfig
),
2018-12-08 01:21:39 +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'
)
}
2018-12-05 00:37:31 +03:00
config.module.rules.push({
test: /\.svg$/,
2018-12-05 11:59:45 +03:00
use: '@svgr/webpack'
2018-12-05 00:37:31 +03:00
})
config.module.rules.push({
2018-12-08 01:21:39 +03:00
test: /\.mdx?$/,
2019-02-12 00:58:10 +03:00
use: [options.defaultLoaders.babel, require.resolve('./mdx-loader')]
})
configured = true
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}