I'm developing a project that consists in both a chrome extension and a spa. And, here is my problem: I have a lot of javascript that is common to both parts, what I'd like to do is:
- Serve the SPA through the regular asset pipeline (application.js)
- Serve common javascript to be consumed by the chrome extension with a regular route. (Say
example.com/chrome-extension/application.js
).
Ideally this response (2) would have both data (from ruby) and the regular result of an asset pipeline.
File: app/views/chrome-extension/application.js.erb
Global.data = { somekey: '<%= @some_value %>' }
# append, inline, the same results that I'd get from `application.js` or, even better, from a second asset pipeline `chrome-extension.js`"
Any thoughts? :D