imgurl-loader
v1.0.1
Published
webpack中的js读取图片资源,返回资源数组给前端
Downloads
8
Readme
Description
在webpack中,读取文件夹下的图片资源,返回资源路径数组
Install
npm install imgurl-loader --save-dev
Webpack Config
...
module: {
rules: [
{
test: /\.js$/,
include:/src/,
use: [{
loader:'imgurl-loader'
}]
},
//图片处理
{
test: /\.(png|jpg|jpeg|gif|svg)$/,
use: [{
loader: 'file-loader',
options: {
outputPath: 'img',
name: '[name]_[contenthash:8].[ext]'
}
}]
}
],
},
Usage
//将img文件夹下的所有文件列出来,返回数组
let resList = __getPath("img");