[英]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));
此方法將在調用回調之前加載模塊並應用所有加載器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.