1
1
import path from "path" ;
2
2
3
- import { klona } from "klona/full" ;
4
-
5
3
/* eslint-disable class-methods-use-this */
6
4
const trailingSlash = / [ / \\ ] $ / ;
7
5
@@ -152,19 +150,18 @@ function createWebpackLessPlugin(loaderContext, implementation) {
152
150
}
153
151
154
152
/**
155
- * Get the less options from the loader context and normalizes its values
153
+ * Get the ` less` options from the loader context and normalizes its values
156
154
*
157
155
* @param {object } loaderContext
158
156
* @param {object } loaderOptions
159
157
* @param {object } implementation
160
158
* @returns {Object }
161
159
*/
162
160
function getLessOptions ( loaderContext , loaderOptions , implementation ) {
163
- const options = klona (
161
+ const options =
164
162
typeof loaderOptions . lessOptions === "function"
165
163
? loaderOptions . lessOptions ( loaderContext ) || { }
166
- : loaderOptions . lessOptions || { }
167
- ) ;
164
+ : loaderOptions . lessOptions || { } ;
168
165
169
166
const lessOptions = {
170
167
plugins : [ ] ,
@@ -174,18 +171,17 @@ function getLessOptions(loaderContext, loaderOptions, implementation) {
174
171
...options ,
175
172
} ;
176
173
174
+ const plugins = lessOptions . plugins . slice ( ) ;
177
175
const shouldUseWebpackImporter =
178
176
typeof loaderOptions . webpackImporter === "boolean"
179
177
? loaderOptions . webpackImporter
180
178
: true ;
181
179
182
180
if ( shouldUseWebpackImporter ) {
183
- lessOptions . plugins . unshift (
184
- createWebpackLessPlugin ( loaderContext , implementation )
185
- ) ;
181
+ plugins . unshift ( createWebpackLessPlugin ( loaderContext , implementation ) ) ;
186
182
}
187
183
188
- lessOptions . plugins . unshift ( {
184
+ plugins . unshift ( {
189
185
install ( lessProcessor , pluginManager ) {
190
186
// eslint-disable-next-line no-param-reassign
191
187
pluginManager . webpackLoaderContext = loaderContext ;
@@ -194,6 +190,8 @@ function getLessOptions(loaderContext, loaderOptions, implementation) {
194
190
} ,
195
191
} ) ;
196
192
193
+ lessOptions . plugins = plugins ;
194
+
197
195
return lessOptions ;
198
196
}
199
197
0 commit comments