Skip to content

Instantly share code, notes, and snippets.

@szy0syz
Last active March 11, 2021 03:27
Show Gist options
  • Save szy0syz/2704b54e171fb6881409259b15f5a3a9 to your computer and use it in GitHub Desktop.
Save szy0syz/2704b54e171fb6881409259b15f5a3a9 to your computer and use it in GitHub Desktop.
@next.js

next.js + ant-design

  • 项目根目录创建 babel.config.js
module.exports = {
  presets: ['next/babel'],
  plugins: [
    [
      'import',
      {
        libraryName: 'antd',
        libraryDirectory: 'lib',
        style: function (name) {
          return `${name}/style/index.css`;
        }
      }
    ],
    [
      'import',
      {
        libraryName: '@ant-design/icons',
        libraryDirectory: 'lib/icons',
        camel2DashComponentName: false
      },
      '@ant-design/icons'
    ]
  ]
};
  • yarn add -D babel-plugin-import

  • 处理按需引入menu等组件时动画效果异常问题

// [_app.js] append
import "antd/lib/style/index.css";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment