javascript - file-loader webpack 2 load directory -


i've added in config:

{     test: /assets\/(\.png|\.jpg)$/,     use: ['file-loader?name=[name].[ext]&publicpath=assets/&outputpath=assets/'] }  

i have bunch of images in assets directory , want output both web-dev-server , dist same folder full of images.

i assumed test pick every png or jpg in folder , set both public , output paths assets.

however webpack output says isn't case.

the regular expression you're using doesn't match files. matches are:

assets/.png assets/.jpg 

you need add .* match between assets/ , extensions. correct regular expression is:

/assets\/.*(\.png|\.jpg)$/ 

if don't want match assets/.png can use .+ instead, shouldn't problem.

you can try in regexr.


just make sure there no additional confusion: rules in webpack config won't include anything, applied imports pass test (match regular expression in case). still need import them in code, give path output file, reference correct.


Comments