We should find a way to include vue.js conditionally. In development, we should include unminified version of vue.js to be able to use the Vue DevTools but in production we should include vue.min.js.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Edit: @jschatz1 points out to me over Slack that the issue isn't just minification, vue.js and vue.min.js are actually different in that the latter strips debugging statements that are in the former. We could do this:
// vendor/assets/javascripts/vue.full.js// Full vue.js
Because Rails will precompile the assets for production, the Ruby code in vue.js.erb is NOT executed on every page load, just on precompilation, so that the right file (vue.min.js) ends up in the fully compiled JS.
I second to @grzesiek. In general I don't like the idea of checking which environment we're running at the moment, because that would make creating another environment hard, and we would have conditions over the places. So setting the name in config/environments/development.rb and config/environments/production.rb and so on so forth would be preferable for me. Or we could check environment variables. I used to have a .env file to setup some additional global configuration based on environment variable, so it could be easily overwritten by env SOME=THING ./run app for example.
I used to have npm and bower along with Rails as well as @lbennett pointed out. The bad side of that is it's not playing very well with Rails assets pipeline, so beware of incompatibilities! As far as I know, the "Rails way" to do that would be using https://rails-assets.org/ which I am not a fan of, due to an extra layer and yet another thing we need to trust. But if it works...
@godfat Doesn't sprockets check and load (when required) anything in vendor/assets? If so we can just set the deps root directory as vendor/assets? Then npm i or bower i will just dump all of our deps in vendor/assets as they are currently.
@lbennett The thing is not everything could be handled by sprockets, i.e. rake assets:precompile could fail on some random stuffs installed by npm or bower. The first example popped from my memory is that jquery has some partial JavaScript in their repository, which they have some scripts to compile with, but sprockets tried to compile those partial JavaScript and then complaining about syntax error. There were also a lot of "special rules" I need to define to exclude from, which were not trivial and the rules could go on for various different packages. It's a pain to maintain them.