File to import not found or unreadable: compass

前端 未结 5 1543
野趣味
野趣味 2020-12-05 02:14

I successfully installed Sass, but I\'m having trouble importing Compass.

The following is the error detail:

*Syntax error: File to import not found          


        
相关标签:
5条回答
  • 2020-12-05 02:18

    Compass adjusts the way partials are imported. It allows importing components based solely on their name, without specifying the path.

    Before you can do @import 'compass';, you should:

    Install Compass as a Ruby gem:

    gem install compass
    

    After that, you should use Compass's own command line tool to compile your SASS code:

    cd path/to/your/project/
    compass compile
    

    Note that Compass reqiures a configuration file called config.rb. You should create it for Compass to work.

    The minimal config.rb can be as simple as this:

    css_dir =   "css"
    sass_dir =  "sass"
    

    And your SASS code should reside in sass/.

    Instead of creating a configuration file manually, you can create an empty Compass project with compass create <project-name> and then copy your SASS code inside it.

    Note that if you want to use Compass extensions, you will have to:

    1. require them from the config.rb;
    2. import them from your SASS file.

    More info here: http://compass-style.org/help/

    0 讨论(0)
  • 2020-12-05 02:26

    In short, if you've installed the gem the run:

    compass compile
    

    in your rails root dir

    0 讨论(0)
  • 2020-12-05 02:32

    If you're like me and came here looking for a way to make sass --watch work with compass, the answer is to use Compass' version of watch, simply:

    compass watch
    

    If you're on a Mac and don't yet have the gem installed, you might run into errors when you try to install the Compass gem, due to permission problems that arise on OSX versions later than 10.11. Install ruby with Homebrew to get around this. See this answer for how to do that.

    Alternatively you could just use CodeKit, but if you're stubborn like me and want to use Sublime Text and command line, this is the route to go.

    0 讨论(0)
  • 2020-12-05 02:35

    I was uninstalled compass 1.0.1 and install compass 0.12.7, this fix problem for me

    $ sudo gem uninstall compass
    $ sudo gem install compass -v 0.12.7
    
    0 讨论(0)
  • 2020-12-05 02:41

    I'm seeing this issue using Rails 4.0.2 and compass-rails 1.1.3

    I got past this error by moving gem 'compass-rails' outside of the :assets group in my Gemfile

    It looks something like this:

    # stuff
    gem 'compass-rails', '~> 1.1.3'
    group :assets do
      # more stuff
    end
    
    0 讨论(0)
提交回复
热议问题