2020-05-07 01:00:48 +02:00
|
|
|
/* eslint-disable */
|
|
|
|
const withLess = require('@zeit/next-less')
|
|
|
|
const lessToJS = require('less-vars-to-js')
|
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
2017-05-27 14:22:13 +02:00
|
|
|
|
2020-05-07 01:00:48 +02:00
|
|
|
// Where your antd-custom.less file lives
|
|
|
|
const themeVariables = lessToJS(
|
|
|
|
fs.readFileSync(path.resolve(__dirname, './assets/antd-custom.less'), 'utf8')
|
|
|
|
)
|
|
|
|
|
|
|
|
module.exports = withLess({
|
|
|
|
lessLoaderOptions: {
|
|
|
|
javascriptEnabled: true,
|
|
|
|
modifyVars: themeVariables, // make your antd custom effective
|
|
|
|
},
|
2019-06-04 11:13:11 +02:00
|
|
|
webpack: (config, { isServer }) => {
|
|
|
|
if (isServer) {
|
2020-05-07 01:00:48 +02:00
|
|
|
const antStyles = /antd\/.*?\/style.*?/
|
2019-06-04 11:13:11 +02:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
},
|
2019-11-11 04:24:53 +01:00
|
|
|
...(typeof origExternals[0] === 'function' ? [] : origExternals),
|
2019-06-04 11:13:11 +02:00
|
|
|
]
|
2017-05-27 14:22:13 +02:00
|
|
|
|
2019-06-04 11:13:11 +02:00
|
|
|
config.module.rules.unshift({
|
|
|
|
test: antStyles,
|
2019-11-11 04:24:53 +01:00
|
|
|
use: 'null-loader',
|
2019-06-04 11:13:11 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return config
|
2019-11-11 04:24:53 +01:00
|
|
|
},
|
2019-06-04 11:13:11 +02:00
|
|
|
})
|