Skip to content

Working with Frontend Assets

Shen Yang edited this page Jun 14, 2023 · 6 revisions

In this project, all of the javascript is bundled together and loaded on every page with only a few exceptions. There are 2 bundles one for the main application and one for all casa admin pages. This is so the client can use a cached version every page load after the first one. The same is done with css.

Javascript for the app is found in app/javascript.
All other assets including styles are found in app/assets.
Styles are written as sass and compiled down to css. Regular css is supported in .scss files.

To compile javascript once, run yarn build
If you are editing javascript run yarn build:dev. This will compile your javascript every time you edit a js file.

Similarly
To compile css once, run yarn build:css
If you are editing javascript run yarn build:css:dev. This will compile your css every time you edit a js file.

Be careful not to run the rake command precompile assets. If you have assets in the public folder, rails will look for assets here instead of app/assets/builds/ where our assets are expected to be built.