這裏將 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 } ] ] } }