Skip to content

Commit 1834f6b

Browse files
fix(customizers/webpack) error in loading postcss loader when using less in webpack 5
1 parent 7e97127 commit 1834f6b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/customizers/webpack.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ export const addLessLoader = (loaderOptions = {}, customCssModules = {}) => conf
143143
const publicPath = config.output.publicPath;
144144
const shouldUseRelativeAssetPaths = publicPath === "./";
145145

146+
const { version } = require('webpack');
147+
const webpackVersion = version.split(".")[0] * 1
148+
146149
// copy from react-scripts
147150
// https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/webpack.config.js#L93
148151
const getStyleLoaders = (cssOptions, preProcessor) => {
@@ -156,7 +159,7 @@ export const addLessLoader = (loaderOptions = {}, customCssModules = {}) => conf
156159
loader: require.resolve("css-loader"),
157160
options: cssOptions
158161
},
159-
{
162+
webpackVersion < 5 && {
160163
loader: require.resolve("postcss-loader"),
161164
options: {
162165
ident: "postcss",

0 commit comments

Comments
 (0)