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

Global styles not included in production build #7

Closed llamadeus closed 3 years ago

llamadeus commented 3 years ago

When I create a production build of my Next.js project, global ant design styles are not being applied on pages with no ant design components, even when I import antd/dist/antd.less directly within my _app.js file.

Reproducible setup:

/// package.json
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "antd": "^4.6.5",
    "babel-plugin-import": "^1.13.0",
    "next": "9.5.3",
    "next-plugin-antd-less": "^0.0.6",
    "react": "16.13.1",
    "react-dom": "16.13.1"
  }
}
/// .babelrc
{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    [
      "import",
      {
        "libraryName": "antd",
        "style": true
      }
    ]
  ]
}
/// next.config.js
const withAntdLess = require('next-plugin-antd-less');

module.exports = withAntdLess();
/// pages/_app.js
import 'antd/dist/antd.less'; // This basically does nothing

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
};
/// pages/index.js
export default function Home() {
  return (
    <div>
      <h1>Hallo Welt!</h1>
    </div>
  );
}
SolidZORO commented 3 years ago

you can try current version 0.1.3, it's support.