rsnext/examples/with-ant-design/next.config.js
JJ Kasper 725f8c2b64 Update ant design examples (#7490)
* Update with-ant-design example to not
need require.extensions hack

* Update other ant-design examples to not
use require.extensions hack
2019-06-04 11:13:10 +02:00

28 lines
769 B
JavaScript

/* eslint-disable */
const withCss = require('@zeit/next-css')
module.exports = withCss({
webpack: (config, { isServer }) => {
if (isServer) {
const antStyles = /antd\/.*?\/style\/css.*?/
const origExternals = [...config.externals]
config.externals = [
(context, request, callback) => {
if (request.match(antStyles)) return callback()
if (typeof origExternals[0] === 'function') {
origExternals[0](context, request, callback)
} else {
callback()
}
},
...(typeof origExternals[0] === 'function' ? [] : origExternals),
]
config.module.rules.unshift({
test: antStyles,
use: 'null-loader',
})
}
return config
},
})