Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const withLess = require('@zeit/next-less')
- const withCSS = require('@zeit/next-css');
- const lessToJS = require('less-vars-to-js')
- const fs = require('fs')
- const path = require('path')
- const withPlugins = require('next-compose-plugins');
- // Where your antd-custom.less file lives
- const themeVariables = lessToJS(
- fs.readFileSync(path.resolve(__dirname, './assets/antd-custom.less'), 'utf8')
- )
- const nextConfig = {
- 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
- },
- };
- module.exports = withPlugins(
- [
- [withCSS],
- [
- withLess,
- {
- cssModules: true,
- cssLoaderOptions: {
- localIdentName: '[path]___[local]___[hash:base64:5]',
- },
- },
- ],
- ],
- nextConfig,
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement