如何在自定义 webpack 加载器中解析 require 字符串

How to resolve a require string within a custom webpack loader

我正在为 webpack 编写自定义加载器。

在我的加载程序中,我有一个像这样的要求字符串:

"css!less!./myFile.less"

有没有办法获取已解析请求的输出?

我正在寻找应用所有加载程序后模块的输出。或者换句话说:

如何从上面的字符串中获取编译后的 css?

我尝试在加载程序上下文中使用 this.resolve

this.resolve(this.context, "css!less!./myFile.less", function(err, result){
     // Best case scenario so far: 
     // result == "./myFile.less"

     // How do I get the css from myFile.less here? 
     // Is that even possible/the right way to get this?
});

但我似乎无法获得已解析的输出。 我可能做错了什么,我找到的关于此功能的唯一文档是:http://webpack.github.io/docs/loaders.html#resolve

有一个(到目前为止)未记录的方法:

this.loadModule(request, callback:function(err, source));

此方法将在调用回调之前加载模块并应用所有加载器。