question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

style is broken on build but works on dev env

See original GitHub issue

Hi there I’m trying to use this plugin in my project I’m using

1. "next": "^10.0.5"
2. "antd": "^4.16.0"
3. "next-plugin-antd-less": "^1.8.0"
4. "less": "^4.1.2"

and here is my next config file

const withPlugins = require("next-compose-plugins");
const { getThemeVariables } = require("antd/dist/theme");
const lessToJS = require("less-vars-to-js");
const fs = require("fs");
const path = require("path");

// antd custom variables
const themeVariables = lessToJS(
  fs.readFileSync(
    path.resolve(__dirname, "./styles/antd-variables.less"),
    "utf8"
  )
);
const antdLessConfig = {
  modifyVars: {
    ...getThemeVariables({
      dark: true, // Enable dark mode
    }),
    ...themeVariables,
  },
  webpack(config) {
    return config;
  },
};
module.exports = withPlugins([[withAntdLess, antdLessConfig]]);

Everything is working fine on running yarn dev image but on run yarn build then yarn start I found the style is broken image all the styles i added is not used

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
SolidZOROcommented, Jan 30, 2022

@NickBeukema hi, you just change _app.tsx import "./global.less" to require('./global.less'); can be fixed this problem. ref. https://github.com/SolidZORO/next-plugin-antd-less#how-to-import-global-less-style-eg-stylesless

I just know it works but I don’t know why.

0reactions
arielszabocommented, Jul 20, 2022

Hi @SolidZORO, I’m having a similar issue with

  1. “next”: “12.2.1”
  2. “next-plugin-antd-less”: “1.8.0”
  3. “antd”: “4.21.5”
  4. “less”: “3.13.1”

When I run next dev the styles are looking fine but when building the project it seems like antd components with custom css style have the original antd style without the class I’ve created.

Would love your help here 😃 Thanks,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styles broken in CRA Production Build but work fine ... - GitHub
My CRA-based PWA application with emotion styles works perfectly during development yarn start, however when built for production yarn build ...
Read more >
The css style is not the same in development environment and ...
I think this is a problem of order of CSS definition. The development and production CSS definition order might be different.
Read more >
Compiled CSS doesn't work as it should in production
Hi all, I just ran into this same issue. Everything works fine on development. When I run yarn build assets are compiled and...
Read more >
Troubleshooting Common Errors - Gatsby
Inconsistent CSS styles between develop and build using styled-components or ... However, when your packaged Gatsby code runs, your computer is but a ......
Read more >
Known issues with Android Studio and Android Gradle Plugin
To fix the issue for the current project, click Run > Edit Configurations and change the default JUnit configuration to only include the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found