Skip to content

Instantly share code, notes, and snippets.

@ueaner
Forked from chitru/next-antd-saas.js
Created November 21, 2021 00:19
Show Gist options
  • Select an option

  • Save ueaner/51ac7d0aabea2dbf1d4c06830f4fae7c to your computer and use it in GitHub Desktop.

Select an option

Save ueaner/51ac7d0aabea2dbf1d4c06830f4fae7c to your computer and use it in GitHub Desktop.
Nextjs project with antd and saas
const withCss = require('@zeit/next-css')
const withSaas = require('@zeit/next-sass')
module.exports = withCss(withSaas({
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
},
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment