config
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'js/[name].js'
}
----------
test: /\.(png|jpg|jpeg|gif)$/,
use: [{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
publicPath: './',
outputPath: 'images/'
}
}]
目录
src
--images
----icon
------xxx.png
⬇︎
dist
--src
----images
------icon
--------xxx.png
[path]是基于什么的?
file-loader里的path以你webpack的output的publicPath为基准
--编辑更新--
@ZivGit[ZivGit]
我自己这边用的url-loader,其实它也是基于file-loader,你可以参考下,我这边目录结构是
loader配置
output配置
最终输出到