How to handle Bootstrap with less.rb outside of Rails

I am trying to create a standalone application (regardless of the Rails resource pipeline) using less.rb to output Twitter Bootstrap based CSS files.

The following results in a blank document

parser = Less::Parser.new :paths => [Rails.root + '/public/bootstraps/twitter-bootstrap-857b8fb/less'] tree = parser.parse("@import 'bootstrap.less'") tree.to_css 

This returns an empty string. I have tried options for changing @import as a full path, etc., without success. I think I should skip something simple.

+7
source share
4 answers

I believe that you have a problem with the way you indicate your path. As far as I can tell, Less is looking for an array of String objects, not Path obejcts.

Use the following:

 parser = Less::Parser.new paths: [Rails.root.join('public', 'bootstraps', 'twitter-bootstrap-857b8fb', 'less').to_s] tree = parser.parse("@import 'bootstrap.less'") tree.to_css 
+1
source

You can just run make , as you described here: https://github.com/twitter/bootstrap/wiki/Contributing-to-Bootstrap

0
source

If performance is not a particular concern, you can always include less.js, which will compile fewer files at run time. Detailed instructions are here .

0
source

Do you consider using the file name syntax on the less.rb github page? https://github.com/cowboyd/less.rb/

 parser = Less::Parser.new :paths => ['./lib', 'other/lib'], :filename => 'mystyles.less' 
0
source

All Articles