file-loader及url-loader的使用


file-loader主要用來處理圖片,其實也可以在js和html及其他文件上,但很少那么使用,比如:

1 require("file-loader?name=js/[hash].script.[ext]!./javascript.js");
2 // => js/0dcbbaa701328a3c262cfd45869e351f.script.js
3 
4 require("file-loader?name=html-[hash:6].html!./page.html");
5 // => html-109fa8.html
6 
7 require("file-loader?name=[hash]!./flash.txt");
8 // => c31e9820c001c9c4a86bce33ce43b679

url-loader是file-loader的加強版,可以使用limit參數

{test:/\.(png|jpg)$/,loader:"url-loader?limit=8192&name=img/[name][hash:8].[ext]"}

 NOTE:file-loader和url-loader只處理入口節點中有引用的圖片


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM