Skip to content

Instantly share code, notes, and snippets.

@AlbionaHoti
Created October 11, 2020 14:40
Show Gist options
  • Save AlbionaHoti/9f019ba783ac516b4c25cc6d58638946 to your computer and use it in GitHub Desktop.
Save AlbionaHoti/9f019ba783ac516b4c25cc6d58638946 to your computer and use it in GitHub Desktop.
webiny-starter-e-commerce-nextjs-stripe
/* eslint-disable */
const withLess = require('@zeit/next-less')
const lessToJS = require('less-vars-to-js')
const fs = require('fs')
const path = require('path')
// 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
},
webpack: (config, { isServer }) => {
if (isServer) {
const antStyles = /antd\/.*?\/style.*?/
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