vue.js - How does Laravel Elixir package files separately?
曾经蜡笔没有小新2017-05-16 16:47:18
0
1
829
The files packaged by mix.webpack('main.js') are too large. How to package dependency files and program files separately? Seek the guidance of the great God
Please refer to: Vendor Extraction introduction of Laravel Mix documentation: http://d.laravel-china.org/do...
One potential drawback of bundling your application's JavaScript with dependent libraries is that it makes long-term caching more difficult. For example, a separate update to the application code will force the browser to re-download all dependent libraries, even if they have not changed.
If you plan to frequently update your application's JavaScript, you should consider extracting all dependent libraries into separate files. This way, changes to the application code do not affect the cache of the vendor.js file. Mix’s extract method makes it easy:
extract method accepts an array of all dependent libraries or modules you wish to extract into the vendor.js file. Using the above code snippet as an example, Mix will generate the following files:
public/js/manifest.js: Webpack display runtime
public/js/vendor.js: dependent library
public/js/app.js: application code
To avoid JavaScript errors, be sure to load these files in the correct order:
Please refer to: Vendor Extraction introduction of Laravel Mix documentation: http://d.laravel-china.org/do...
One potential drawback of bundling your application's JavaScript with dependent libraries is that it makes long-term caching more difficult. For example, a separate update to the application code will force the browser to re-download all dependent libraries, even if they have not changed.
If you plan to frequently update your application's JavaScript, you should consider extracting all dependent libraries into separate files. This way, changes to the application code do not affect the cache of the vendor.js file. Mix’s extract method makes it easy:
Theextract method accepts an array of all dependent libraries or modules you wish to extract into the vendor.js file. Using the above code snippet as an example, Mix will generate the following files:
public/js/manifest.js: Webpack display runtime
public/js/vendor.js: dependent library
public/js/app.js: application code
To avoid JavaScript errors, be sure to load these files in the correct order: