We use WebPack to pre-compile all our assets. Webpacker will be native in Rails 6 but we are pulling it in for 5.2 to manage all of our JS dependencies. Stylesheets, fonts and images are still managed by Sprockets and the Asset Pipeline
In order for your JS to work you will need to run the following (after bundle install)
to install of the JS dependencies:
yarn install
To add or remove JS dependencies you can run one of the following:
yarn add [dependency-name]
yarn remove [dependency-name]
This will add/remove the dependency from the package.json + yarn.lock file which serves a purpose similar to Rails' Gemfile + Gemfile.lock.
Webpacker adds a hook into Rails assets:precompile task, so all you need to do to
compile your assets for production is:
rails assets:precompile
Webpacker uses the webpack-dev-server by default when running in the Rails
development environment. The dev server will mobitor your JS files for changes and
will recompile on the fly when you refresh the browser page. Check the Rails log
for errors/warnings generated by this compilation.
We use jasmine to write unit tests together with karma for testing in real browser our functionality. Please type the following command to execute every test for JavaScript modules.
karma