create-react-app 配置 less
安装less-loader 和 less npm install less-loader less --save-dev 修改 webpack.config.dev.js 和 webpack.config-prod.js 配置文件 exclude: [ /\.html$/, /\.(js|jsx)$/, /\.(css|less)$/, //需要修改的地方 /\.json$/, /\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, ], { test: /\.(css|less)$/, //需要修改的地方 use: [ require.resolve('style-loader'), { loader: require.resolve('css-loader'), options: { importLoaders: 1, }, }, { loader: require.resolve('postcss-loader'), options: { // Necessary for external CSS imports to work // https://github.com/facebookincubator/create-react-app/issues/2677 ident: 'postcss', plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ browsers: [ '>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway ], flexbox: 'no-2009', }), ], }, }, //需要修改的地方 { loader: require.resolve('less-loader') // compiles Less to CSS } ], }