Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在自定义网页包加载器中解析require字符串_Javascript_Webpack - Fatal编程技术网

Javascript 如何在自定义网页包加载器中解析require字符串

Javascript 如何在自定义网页包加载器中解析require字符串,javascript,webpack,Javascript,Webpack,我正在为webpack编写一个自定义加载程序 在我的加载程序中,我有一个如下所示的require字符串: "css!less!./myFile.less" 是否有办法获得已解决请求的输出? 我正在寻找所有加载程序应用后的模块输出。换句话说: 如何从上面的字符串中获取已编译的css? 我尝试在加载程序上下文中使用this.resolve: this.resolve(this.context, "css!less!./myFile.less", function(err, result){

我正在为webpack编写一个自定义加载程序

在我的加载程序中,我有一个如下所示的require字符串:

"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?
});
但我似乎无法获得已解决的输出。 我可能做错了什么,我找到的关于这个函数的唯一文档就在这里:

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

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

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

您能描述一下整个任务吗?为什么在加载程序中需要外部模块?