Automatic switching between full and minified files

While using the bootstrap and jQuery libraries in a RubyMine project, I want to refer to the full bootstrap.css files and the full jquery.js files, so that I can easily look stuff up using cmd-B. Then, of course, I want to link to the minified versions when uploading. There ought to be an automatic way of doing this that I'm missing. Right now my html files look like:

 
<!-- Bootstrap -->
<!--<link href="css/bootstrap.min.css" rel="stylesheet">-->
<!--<link href="css/bootstrap-theme.min.css" rel="stylesheet">-->

<!-- These are active during editing -->
<link rel="stylesheet" href="css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap-theme.css" rel="stylesheet">


Then I have to comment/uncomment in every file. This can't be right.

6 comments
Comment actions Permalink

It seems very similar to what rake task for precompiling assets would do:

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

0
Comment actions Permalink

Olga,

I was hoping for something simpler. Also, using the rake task minifies the files for the upload, which is fine in itself, but I want to change the link from local source files to CDN based minified files that already exist, not produce my own minified files.

0
Comment actions Permalink

Martin,

in this case you can specify different paths depending on what environment will be used, i.e.:

 
<% if Rails.env.production? %>
<!-- Bootstrap -->
    <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap-theme.css" rel="stylesheet">
<% else
%>
    <link rel="stylesheet" href="css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap-theme.css" rel="stylesheet">
<% end
%>
0
Comment actions Permalink

Isn't this only if the project is actually Rails? I'm doing this in a bootstrap/jQuery project. Yes, I'm using RubyMine, but not RoR.

0
Comment actions Permalink

Yes, indeed, that's for Rails.. I'm afraid in this case there is no solution we can offer at the moment, but we have a feature request for downloading external stylesheets, please take a look:

https://youtrack.jetbrains.com/issue/WEB-10023

0
Comment actions Permalink

Yes, indeed, that youtrack issue describes my problem, too. We need some way to get code completion and lookup while still using the CDN files.

0

Please sign in to leave a comment.