[email protected] 引入antd 按需加载报错

yarn add webpack@webpack-4

在.babelrc引入

"plugins": [

    [

      "import",

      {

        "libraryName": "antd",

        // true 的时候才会编译less

        "style": true

      }

    ],

修改在next.config.js

withCSS({

    // 添加

    cssModules: true,

    cssLoaderOptions: {

      importLoaders: 1,

      localIdentName: "[local]___[hash:base64:5]"

    },

    ...withLess(

      withSass({

        lessLoaderOptions: {

          javascriptEnabled: true

        }

      })

    ),

你可能感兴趣的:([email protected] 引入antd 按需加载报错)