Sprockets yog a Ruby lub tsev qiv ntawv rau kev sau thiab ua haujlwm hauv lub vev xaibSprockets tso cai los teeb tsa ib daim ntawv thov cov ntaub ntawv JavaScript rau hauv me me dua cov chunks uas tuaj yeem faib tawm ntau ntawm cov npe thiab cov ntaub ntawv. Nws muab cov qauv thiab kev coj ua ntawm yuav ua li cas suav nrog cov cuab tam hauv peb cov haujlwm.
Rails cov cuab tam yog dab tsi?
Cov khoom vaj khoom tsev xa khoom muab lub hauv paus rau kev sib koom ua ke thiab txo qis lossis compress JavaScript thiab CSS cov cuab tam. Nws kuj tseem ntxiv lub peev xwm los sau cov cuab tam no ua lwm hom lus thiab cov txheej txheem ua ntej xws li CoffeeScript, Sass, thiab ERB. … Cov khoom vaj khoom tsev raj siv tau los ntawm cov pob zeb sprockets-rails, thiab tau qhib los ntawm lub neej ntawd.
Yuav ua li cas tshem lub sprocket ntawm Rails?
Tshem Tawm Sprockets
- pob tshem tawm sass-rails.
- rm config/initalizers/assets.rb.
- Hloov xav tau 'rails / tag nrho' hauv config/application.rb nrog cov kab no hloov: …
- Tshem tawm cov kab no los ntawm config/application/development.rb. …
- Tshem cov kab no los ntawm config/application/production.rb.
Kuv puas xav tau Webpacker?
New Rails apps tau teeb tsa siv webpack rau JavaScript thiab Sprockets rau CSS, txawm hais tias koj tuaj yeem ua CSS hauv webpack. Koj yuav tsum xaiv Webpacker hla Sprockets ntawm qhov project tshiab yog tias koj xav siv NPM pob thiab / lossis xav nkag mus rau cov yam ntxwv tam sim no thiab cov cuab yeej JavaScript.
Cov cuab tam Precompile yog dab tsi?
RAILS_ENV=kev tsim cov khoom muaj nqis: ua ntej. RAILS_ENV=ntau lawm qhia Rails los sau cov khoom tsim tawm ntawm cov cuab tam. khoom muaj nqis:precompile yog a Rails muab rake txoj haujlwm uas muaj cov lus qhia rau kev suav cov khoom muaj nqis.