File-loader returns the url of the image
The url-loader can process the picture by the limit attribute. When the picture is smaller than the limit (unit: byte), it will be converted to base64. When the limit is greater than the limit, the file-loader is called to process the picture.
The same point: all files, font icons and other files are processed in webpack.
Relationship: url-loader encapsulates file-loader, but url-loader does not depend on file-loader.
There is a list in the project. The image is looped through v-for. If the url is placed in js, it cannot be converted to base64. The url-loader will only compile images in html and css. You can import images by import, receive them with a variable, and then render the variables in v-for.
import beijing from './static/images/4.png';
import shanghai from './static/images/5.png';
import shenzhen from './static/images/6.png';
[
{
Name: 'Beijing',
src: beijing
},
{
Name: 'Shanghai',
src: shanghai
},
{
Name: 'Shenzhen',
src: shenzhen
}
]
If the url-loader exceeds imit, it will fallback, so the file-loader configuration must be written in the fallback. If you finish writing the url-loader configuration and then write the file-loader as...
npm install --save-dev [email protected] Configuration in WebPack.config.js npm install --save-dev [email protected] Then add it in WebPack.config.js publicPath: 'dist/'...
Custom loader...
1、file-loader ** In actual development, the introduction of pictures generally have two, IMG and Background-Image, 1.1, Background-Image Settings Background The class name Hulu1 here is changed to Hul...
Installation webpack Webpack command execution npx command that the implementation of the project in webpack node_modules commands executed directly webpack otherwise, you will need to install a globa...
Original address:https://webpack.js.org/loaders/url-loader/ webpack version: 2.2.1 Converting image files to base64 encoding and loading into the browser can reduce the number of http requests, but in...
Original address:Detailed webpack loader and plugin First, the common configuration of webpack Second, the packaging principle of webpack Identify entry files By layer-by-layer identification o...
Interview questions: Do you know the principle of webpack? What configuration did we use webpack in your project? What is the difference between loader and plugin? What are used in the project? 【Loade...
1. Webpack image file processing 1.1, picture file processing method 1: url-loader 1.2, picture file processing method 2: file-loader 1.3. Image file processing-modify file name Generate file storage ...
1 Introduction If we want to introduce the picture page (including the url img src and the background). When we webpack-based development, the introduction of the picture will encounter some problems....