Ant Design of React 按需引入CSS和修改全局主题

2,169 次浏览次阅读

1. 安装模块

$ yarn add react-app-rewired customize-cra babel-plugin-import less less-loader

2. 修改 package.json

/* package.json */
"scripts": {
   "start": "react-app-rewired start",
   "build": "react-app-rewireds build",
   "test": "react-app-rewired test",
   "eject": "react-scripts eject"
}

3. 新建 config-overrides.js 并输入

const {override, fixBabelImports,addLessLoader} = require('customize-cra');
module.exports = override(
   fixBabelImports('import', {
       libraryName: 'antd',
       libraryDirectory: 'es',
       style: true,
  }),
   addLessLoader({
       lessOptions: {
           javascriptEnabled: true,
           modifyVars: {'@primary-color': '#1DA57A'},
      }
  }),
);
正文完
 0
yxsoft
版权声明:本站原创文章,由 yxsoft 于2021-01-22发表,共计592字。
转载说明:除特殊说明外本站文章皆由YXSoft发布,转载请注明出处。