How do I get Twitter Bootstrap's Less files to work with Sinatra AssetPack?

喜欢而已 提交于 2019-12-06 02:48:06

There's been a bunch of work on the AssetPack gem recently (with less support now built in). If you update to the latest gem, it's pretty easy to get Less working. This Gist has a full example: https://gist.github.com/4652773.

The best solution I found was to simply add the path to the less files to the Less.path array. There is no need to change any of the original less files.

For example:

require 'sinatra/base'
require 'sinatra/assetpack'

class App < Sinatra::Base
  set :root, File.dirname(__FILE__)
  Less.paths <<  "#{App.root}/app/css" 

  register Sinatra::AssetPack

  assets do
    css :bootstrap, [
      '/css/bootstrap.css'
    ]

  end

  get '/' do
    erb :index
  end

  # start the server if ruby file executed directly
  run! if app_file == $0
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!