码迷,mamicode.com
首页 > Web开发 > 详细

file-loader及url-loader的使用

时间:2016-12-14 01:44:48      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:name   code   blog   文件   amp   txt   flash   log   png   

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只处理入口节点中有引用的图片

file-loader及url-loader的使用

标签:name   code   blog   文件   amp   txt   flash   log   png   

原文地址:http://www.cnblogs.com/toward-the-sun/p/6175595.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!