php - What is the difference between the mix method and asset method in Laravel?
巴扎黑
巴扎黑 2017-05-16 13:09:08
0
1
448

I am new to laravel. When referencing resources, I saw that there are asset methods and mix methods, which both return the same directory. I would like to ask what is the difference between the two?

巴扎黑
巴扎黑

reply all(1)
漂亮男人

Laravel comes with laravel-mix, which is used to package static resources such as js, css, images, etc. The name of the generated file will be: app.asjduiik2l1323879dasfydua23.js, 即js原文件名+hash+.js后缀,因为中间的那个hash是随时会变化的,所以在页面引入js文件的时候,就不能写死文件的路径,而是使用mix('app.js'),此时laravel会自动去匹配当前的app.js对应哪个app+hash+.js的文件(项目public目录下会有一个mix-manifest.json, which stores the corresponding relationship between the two, and the file will be updated every time the static resources are packaged).

Sometimes we don’t want the hash value to be added to the name of the static resource (in most cases, it is a third-party library that is not a nodejs module and is introduced independently). At this time, we can directly use the asset method, which is simple and crude. Look for the file you named it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template