From 66f0fcec291316887f0b6a892f49a3064e467607 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Sat, 21 Mar 2020 01:24:56 +0300 Subject: [PATCH] fix(less): use provided less in importer --- src/loaders/less/import-plugin.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/loaders/less/import-plugin.ts b/src/loaders/less/import-plugin.ts index a4d24612..3e9bb2e4 100644 --- a/src/loaders/less/import-plugin.ts +++ b/src/loaders/less/import-plugin.ts @@ -3,9 +3,8 @@ import { LoadedFile, Plugin, FileManagerInterface, Less } from "less"; import resolveAsync from "../../utils/resolve-async"; import { moduleRe, getUrlOfPartial } from "../../utils/resolve-utils"; -const getStylesFileManager = (): FileManagerInterface => { - const less = require("less") as Less; - return new (class extends less.AbstractFileManager implements FileManagerInterface { +const getStylesFileManager = (less: Less): FileManagerInterface => + new (class extends less.AbstractFileManager implements FileManagerInterface { supports(): boolean { return true; } @@ -50,11 +49,10 @@ const getStylesFileManager = (): FileManagerInterface => { return { filename: id, contents: await fs.readFile(id, "utf8") }; } })(); -}; const importPlugin: Plugin = { - install(_, pluginManager) { - pluginManager.addFileManager(getStylesFileManager()); + install(less, pluginManager) { + pluginManager.addFileManager(getStylesFileManager(less)); }, };