propshaft

Propshaft is an asset pipeline library for Rails. It's built for an era where bundling assets to save on HTTP connections is no longer urgent, where JavaScript and CSS are either compiled by dedicated Node.js bundlers or served directly to the browsers, and where increases in bandwidth have made the need for minification less pressing.

Create a Topic

Topics

SprocketsからPropshaftへの移行に関する注意点

68 views Post
wakairo @wakairo

SprocketsからPropshaftへの移行手順は、 以下のPropshaftの公式手順で基本的には問題ないと思いますが、 この公式手順に記載されていないものを中心に、 移行における注意点をこのTopicで集約できればと思います。

https://github.com/rails/propshaft/blob/main/UPGRADING.md

0
Raw
https://www.techtips.page/en/comments/1078
wakairo @wakairo

Propshaftへの移行に際して、tailwindcss-railsまたはdartsass-railsを選ぶのもあり

Propshaftの公式移行手順では、CSS関連の処理が必要な場合の選択肢として cssbundling-rails のみ紹介されていますが、 tailwindcss-rails と dartsass-rails という選択肢もあります。cssbundling-railsのREADMEには、選び方のヒントが掲載されています。

0
Raw
https://www.techtips.page/en/comments/1079
wakairo @wakairo

Propshaftは.erbを処理しない

Sprocketsは拡張子が .erb のファイル(例: foo.scss.erb)を処理しますが、Propshaftは処理しません。 そのため、Sprockets で .erb を処理している場合、Propshaftへ移行するには次のいずれかの対応が必要になります。

  • .erb の利用をやめ、プレーンなCSS/SCSSなどに書き換える
  • .erb の処理を、Propshaftに渡す前の前処理として別途組み込む
0
Raw
https://www.techtips.page/en/comments/1080
wakairo @wakairo

Propshaftへ移行したらSprockets用の設定は削除可能

config/environments/production.rb にある以下の設定はSprocketsの設定なので、 Propshaftへ移行したら、削除可能です。

config.assets.compile = false

参考情報

https://www.techtips.page/ja/comments/658

0
Raw
https://www.techtips.page/en/comments/1081