A framework for minimizing or compressing and concatenating JavaScript and CSS assets (minify: padding spaces and line breaks, etc.) See: Rails Guide -About AssetPipeline- https://railsguides.jp/asset_pipeline.html
This article is meant to help you better understand the AssetPipeline article in the Rails Guide by giving you an overview of AssetPipeline.
In the first place, coffeescript, sass, erb, etc. are nice because they can be written more easily than raw js / css for ** program writers / readers **, but they are hard to read for ** executing machine side **. These coffeescript, sass, etc. are called high-level languages, but Asset automatically compiles and minifies ** to .js.coffee → .js and .css.sass → .css. The role of Pipeline.
However, ** compilation is done only in the development environment **. In the development environment, as long as you debug with a debugger etc., it is helpful for ** writers / readers ** to keep js / css under development as much as possible.
The definition of compilation here is ** without precompilation **. See below.
So what's going on in the production environment? In a production environment
** 1: Existence of precompiled files ** ** 2: Integrate one file group into one js file and one css file ** ** 3: Compression ** ** 4: Digest grant **
I do. Regarding the precompiled file that came out first, if you compile it even in the production environment, it will be greatly affected by the execution speed of the application. Therefore, ** keep the precompiled files (precompile) ** to keep the execution speed in the production environment.
The flow of the development environment and the production environment is shown in the figure below. Starting from the upper left, the development environment is output in the middle, but the production environment reaches the last lower right.
I hope the above content will deepen your understanding of the Rails guide. https://railsguides.jp/asset_pipeline.html
Recommended Posts