Created
October 24, 2019 10:49
-
-
Save tkreis/7f90350e2dca59d5bf3a4c5ec4bc9fdc to your computer and use it in GitHub Desktop.
How to get less loading with react-app-rewire
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack'); | |
const externals = require('./config-externals'); | |
const packageJson = require('./package.json'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
module.exports = { | |
// The Webpack config to use when compiling your react app for development or production. | |
webpack: function(config, env) { | |
// the file-loader wins if you just append a custom rule to module.rules. | |
const rule = config.module.rules.find(rule => rule.oneOf); | |
rule.oneOf.unshift({ | |
test: /\.less$/, | |
use: [ | |
env === 'production' | |
? MiniCssExtractPlugin.loader | |
: require.resolve('style-loader'), | |
require.resolve('css-loader'), | |
require.resolve('less-loader'), | |
], | |
}); | |
return config; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment