webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 257 forks source link

an option to reserve querystring #326

Closed ghost closed 5 years ago

ghost commented 5 years ago

Feature Proposal

An option to reserve querystring after filename, or an option to define the public filename.

Feature Use Case

I may use some image optimization services provided by CDN operator, such as logo.jpg?imageview/..,but the filename is changed to /publicPath/logo.jpg after build.

If I use the regExp to keep the querystring,it is also used in the output path.

Now that the name is used as the path to export and the filename in the code where we require it.The querystring after filename is ignored on the output.

Do you have any plan about providing an option to keep the querystring?

alexander-akait commented 5 years ago

Hi, can you provide example usage where you need query string, because it is part of webpack and it is not easy to solve

ghost commented 5 years ago

@evilebottnawi I may write this in my stylesheet:

.img { background-image:  url(/resource/Ship.jpg?imageView2/2/w/400/q/85/interlace/1)}

imageView2 means using the image optimization API privided by a CDN operator. q means the quality of the image, and /interlace/1 means that the image will be loaded from blurred to clear at bad network.

publicPath in my configuration is https://odum9helk.qnssl.com. The url is changed to https://odum9helk.qnssl.com/resource/Ship.jpg after building . Since the query string is lost, I can't use the image optimization API.

alexander-akait commented 5 years ago

Not related to file-loader, should be fixed in css-loader (issue already exists)