The difference between public and assets in vue-cli3.x

There are two directories for static resources in vue-cli3.x, public and assets.

the difference:

assets:
Use the resources under assets. If used in js, the path must be compiled by the file-loader in webpack, and the path cannot be written directly. In dynamic binding, images in the asset path will fail to load (because webpack uses the commenJS specification, require (or import) must be used.

Public:
The files in public will not be compiled. After packaging, the dist folder will be generated. The files in public are just copied, and the absolute path must be used to reference these files (this depends on your vue.config.js The configuration of publicPath, the default is / ). Therefore, public recommends that you put some external third parties, your own files in assets, and others in public.

Guess you like

Origin blog.csdn.net/qq_17627195/article/details/109241845