Skip to content

Instantly share code, notes, and snippets.

@tkreis
Created October 24, 2019 10:49
Show Gist options
  • Save tkreis/7f90350e2dca59d5bf3a4c5ec4bc9fdc to your computer and use it in GitHub Desktop.
Save tkreis/7f90350e2dca59d5bf3a4c5ec4bc9fdc to your computer and use it in GitHub Desktop.
How to get less loading with react-app-rewire
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