I have some third party modules in my node_modules
folder in my Rails app.
I want to compile them as assets. So I'm doing:
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Only compile js and css files.
Rails.application.config.assets.precompile.push(Proc.new do |path|
puts path
File.extname(path).in? [
'.js', '.css'
]
end)
In one of the node_modules, there is a file node_modules/somelib/src/style/main.scss
(notice .scss). However, for some reason, this file is still being included in the assets. The output from the above puts path
statement prints:
node_modules/somelib/src/style/main.css
What! Why is it changing it to .css
when it is clearly a .scss
file?
The reason I need to disable this behavior is that the .scss file in question has an @import
statement that Rails doesn't know where to find (rightfully so, it wasn't meant for Rails's eyes.) So it throws an error. I need to exclude this scss file.