create-react-app 在run eject后对antd和sass的配置
2018-01-09 17:55
891 查看
用create-react-app创建项目,但是需要自己配置很多东西的时候,run eject弹出配置项,不可逆操作
在webpack.config.dev.js中进行修改,修改如下:
然后移除前面在 src/App.css 里全量添加的 @import ‘~antd/dist/antd.css’; 样式代码,现在 babel-plugin-import 会按需加载样式。
对sass和less的配置,导出以后,按照官网不导出的方法来操作,最后修改package.json中的script就可以了
react:create-react-app在不run eject的条件下使用less或sass
$ yarn add babel-plugin-import --save-dev
在webpack.config.dev.js中进行修改,修改如下:
{ test: /\.(js|jsx)$/, include: paths.appSrc, loader: 'babel', query: { + plugins: [ + ['import', [{ libraryName: "antd", style: 'css' }]], + ], // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true } },
然后移除前面在 src/App.css 里全量添加的 @import ‘~antd/dist/antd.css’; 样式代码,现在 babel-plugin-import 会按需加载样式。
对sass和less的配置,导出以后,按照官网不导出的方法来操作,最后修改package.json中的script就可以了
react:create-react-app在不run eject的条件下使用less或sass
相关文章推荐
- 在create-react-app创建的React项目应用中配置JQ、Sass
- create-react-app脚手架中配置sass
- create-react-app + antd-mobile配置
- Create-react-app+Antd+Less配置
- ant-design在create-react-app中配置按需加载组件
- create-react-app方式下引入antd
- 详解使用create-react-app添加css modules、sasss和antd
- create-react-app项目添加less配置
- 在基于 create-react-app 的React项目中进行代码分片、按需加载(code splitting)/ 免webpack配置
- Create-React-App创建antd-mobile开发环境
- react create app ,nginx服务器配置
- create-react-app不暴露配置设置proxy代理
- 如何扩展 Create React App 的 Webpack 配置
- 使用Create-React-App脚手架创建antd-mobile开发环境 (附 github 源码)
- Create-React-App创建antd-mobile开发环境
- 使用create-react-app或者antd创建一个React项目
- 基于create-react-app的再配置
- Create-React-App项目外使用它的eslint配置
- Create-React-App创建antd-mobile开发环境
- 详解create-react-app 自定义 eslint 配置