I'm using rails 5.0.3
I've added npm to this project at the applications' root.
In order to load node_modules into the asset pipeline I've added the following line to config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Then I've included angular in my application.js manifest file like so:
//= require angular/angular.js
//= require app.js
//= require_tree ./ng/constants
//= require_tree ./ng/services
//= require_tree ./ng/controllers
I've tried a number of variations such as:
require_directory angular
require_tree angular
require angular/angular.js
require angular
This DOES work locally, but when I push to heroku it says:
Sprockets::FileNotFound: couldn't find file 'angular/angular.js' with type 'application/javascript'
...... [lists all the asset paths Sprockets has searched including node_modules]
/tmp/build_93a7b2eb7cc158c5d30b242da36b56ac/node_modules
It seems that there is something happening when the application is loading the assets in Heroku for production than when it's run locally in development, but what is it?
I've also tried precompiling everything in my manifest file by including this line from config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( application.js )
The way that this works in Heroku for production is by first doing:
rake assets:precompile
Why must I precompile these assets before I push to master? How can I make this part of the default process?
The way we solved this is by installing the webpacker gem and running rails webpacker:install