create-react-app脚手架配置less

恢弘志士之气,不宜妄自菲薄。这篇文章主要讲述create-react-app脚手架配置less相关的知识,希望能为你提供帮助。
npm install -g create-react-app
create-react-app hello-world
npm start
使用npm run eject将webpack配置导出
 
 
修改 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 } ], }

【create-react-app脚手架配置less】 

    推荐阅读