Sven Kirsten
Sven Kirsten

Reputation: 518

Difference between ./bin/webpack and rails assets:precompile?

Starting with RAILS 6 - there are two ways to compile the assets (javascript) when running in DEVELOPMENT mode.

-> ./bin/webpack

-> rails assets:precompile

But what is the difference ?

Upvotes: 1

Views: 2030

Answers (2)

smithWEBtek
smithWEBtek

Reputation: 111

For fun, in a second terminal, run this from the root of your app:

$ bin/webpack-dev-server

that will show you any issues or success compiling webpack assets within app/javascript/

This post was helpful to understand the difference between asset pipeline and webpacker in Rails 6: https://blog.capsens.eu/how-to-write-javascript-in-rails-6-webpacker-yarn-and-sprockets-cdf990387463

Upvotes: 0

user229044
user229044

Reputation: 239382

rails assets:precompile compiles all types of assets, including anything managed by sprockets, ie app/assets/* (CSS, images, fonts, etc). It also compiles Webpack-managed assets.

./bin/webpack only compiles your Webpack-managed assets (typically JavaScript).

Upvotes: 3

Related Questions