这里将 const cssRegex = /\.css$/ 改为 const cssRegex = /\.(css|less)$/;
并配置如下loaderjavascript
{ loader: 'less-loader', options: { javascriptEnabled: true //若是你是less3.x的版本就加上这句话,否则就会报错下图 } },
不一样的版本配置方式不一样,本文以最新版本为例css
{ "name": "coupon-ui", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.8.6", "react-dom": "^16.8.6", "react-scripts": "2.1.8" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] }
使用 babel-plugin-import 配置问题java
"babel": { "presets": [ "react-app" ], "plugins": [ [ "import", { "libraryName": "antd", "style": true } ] ] } }