The vue project optimizes packaging and compressing font files, using font-spider

1. Installation

 npm install font-spider -g

2. Check the version: font-spider -v
shows a version number which means success

3. Because the file suffix produced by the vue packaging project will generate dynamic characters, so we create a new index.html in the folder where the font is stored, import the font file, and the word spider will automatically detect it for us

insert image description here
4. CMD enters the font folder, and input the command font-spider index.html
insert image description here
5. Successful, the size of the font before and after the comparison
insert image description here
insert image description here
has changed from 10m to 2k, and the optimization is extremely high

6. Now, the volume
insert image description here
insert image description here
of 21m before and after packaging has become 6m (three font files have been optimized in my project, because this is a tutorial, so I only wrote one in the index.html code for everyone to view)

Summary: There are three ways to optimize the package size of the vue project
1. Do not generate map files, tutorial
file links 2. Compress font files
3. Turn on gzip compression (this needs to be done together with the back-end, the first two can be optimized separately for the front-end)

Guess you like

Origin blog.csdn.net/weixin_42821697/article/details/123294977