fix: less loader options (#4151)

This commit is contained in:
ClarkXia 2021-03-10 17:19:12 +08:00 committed by GitHub
parent 940c9def1c
commit 9c540a5859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View File

@ -52,6 +52,11 @@ module.exports = (config, customOptions, context) => {
.tap((options) => ({
...options,
...lessLoaderOptions,
// merge less options
lessOptions: {
...(options.lessOptions || {}),
...lessLoaderOptions.lessOptions,
}
}));
}
});

View File

@ -10,11 +10,25 @@ module.exports = async ({ onGetWebpackConfig, log }, pluginOptions = {}) => {
.rule(rule)
.use('less-loader')
.tap((options) => {
const modifyVars = {
...options.modifyVars,
...themeConfig,
if (options.lessOptions) {
return {
...options, lessOptions: {
...(options.lessOptions || {}),
modifyVars: {
...(options.lessOptions.modifyVars || {}),
...themeConfig,
},
}
};
}
// compatible with old less version
return {
...options,
modifyVars: {
...options.modifyVars,
...themeConfig,
},
};
return { ...options, modifyVars };
});
});