zoukankan      html  css  js  c++  java
  • 深坑react 引入antd无效问题

    //安装babel-plugin-import
    第一步:
    npm install babel-plugin-import --save




    第二步:暴露webpack.config.js
    运行:npm run eject


    第三步:在webpack.config.js中的module下的oneOf数组里加入下面代码:

     {//ES6、JSX处理
                  test: /(.jsx|.js)$/,
                  exclude: /node_modules/,
                  loader: 'babel-loader',
                  query:
                  {
                    plugins: [
                      [
                        "import",
                        { libraryName: "antd", style: 'css' }
                      ] //antd按需加载
                    ]
                  },
                },

                {//CSS处理
                  test: /.css$/,
                  loader: "style-loader!css-loader?modules",
                  exclude: /node_modules/,
                },

                {//antd样式处理
                  test: /.css$/,
                  exclude: /src/,
                  use: [
                    { loader: "style-loader", },
                    {
                      loader: "css-loader",
                      options: {
                        importLoaders: 1
                      }
                    }
                  ]
                },

    重启项目即可;
  • 相关阅读:
    php安装xcache (5.4)
    nginx博客系统(内含nginx图片缩略图处理代码,不错)
    一个mysql开启多个端口
    mysql源码重启
    ecshop支付时减库存方法
    n阶幻方问题
    codeforces 710A King Moves(水)
    关于ios::sync_with_stdio(false);和 cin.tie(0)加速c++输入输出流
    codeforces 701C. They Are Everywhere(尺取法)
    codeforces 701 B. Cells Not Under Attack
  • 原文地址:https://www.cnblogs.com/nimon-hugo/p/13150712.html
Copyright © 2011-2022 走看看