SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

Is less-vars-to-js needed after all? #38

Closed nring closed 3 years ago

nring commented 3 years ago

I just upgraded to v1.0.6 of next-plugin-andt-less. I manually removed less-vars-to-js from my package.json and re-built on Heroku. The build failed because the build process didn't know how to handle the @ character in .less files. Such as @primary-color: green;. I was not able to reproduce this with a production build locally. After re-adding less-vars-to-js , the Heroku build succeeds.

My next.config is pretty stripped down as I'm storing my less variables in the Less files themselves:

const withPlugins = require('next-compose-plugins');
const withAntdLess = require('next-plugin-antd-less');

const lessPlugin = withAntdLess({
  cssLoaderOptions: {
    // https://github.com/webpack-contrib/css-loader#object
    sourceMap: true,
  // Other Config Here...
  },
  webpack(config) {
    return config;
  },
});

module.exports = withPlugins([lessPlugin], {
  images: {
    domains: ['...imgDomain...']
  },
  async redirects() {
    return [...myRedirects...];
  },
});

Note, I am importing @import '~antd/lib/style/themes/default.less'; in my global.less file:

@import '~antd/lib/style/themes/default.less';
@import '~antd/dist/antd.less';

@primary-color: #ff0000;
...
SolidZORO commented 3 years ago

hey, @nring, In my project I delete less-vars-to-js is ok, can you do a test to help me make sure? I actually haven't developed with nextjs for a long time, so I don't have a project to test.

nring commented 3 years ago

Apologies! My storybook configuration still depended on less-vars-to-js, my mistake. Removing that configuration or re-adding less-vars-to-js makes the build on Heroku succeed again.