compass: You must compile individual stylesheets from the project directory

前端 未结 6 2299
有刺的猬
有刺的猬 2020-12-29 05:36

A while ago I was using compass to generate stylesheets from sass for a project.

Recently I returned to that project. I went to my sass directory and did \"compass w

相关标签:
6条回答
  • 2020-12-29 05:40

    Had this problem on windows 7 using Symfony with Gulp, i solved it using absolute paths like this:

    gulp.task('compass', function() {
    gulp.src('c:/wamp/www/mnv/src/Mnv/Bundle/MnvBundle/Resources/public/sass/*.scss')
        .pipe(compass({
            config_file: 'c:/wamp/www/mnv/src/Mnv/Bundle/MnvBundle/Resources/public/config.rb',
            css: 'c:/wamp/www/mnv/src/Mnv/Bundle/MnvBundle/Resources/public/stylesheets',
            sass: 'c:/wamp/www/mnv/src/Mnv/Bundle/MnvBundle/Resources/public/sass'
        }))
        .pipe(gulp.dest('c:/wamp/www/mnv/web/css'));
     });
    
    0 讨论(0)
  • 2020-12-29 05:41

    I experienced the same problem using gulp-compass-compile. Fixed that by changing srcDir option (that converts to --sass-dir option in compass compile call) for compass function from ./src/scss to src/scss. Hope that helps someone.

    0 讨论(0)
  • 2020-12-29 05:43

    just came across this problem too, and it has already been answered in the comment by Arnaud Valle. But just for clarity, and people later searching.

    Just creating a config.rb will not work, as compass does not recognise it. The answer is just switch to your project directory(root) and then run

    compass init
    

    This will then create you a "working" config.rb, and two directories called sass, and stylesheets, in the sass directory will be a couple of start scss files.

    If you do not want them, or want to use different directories, you can of course now edit your freshly created and working config.rb, and change your directories (and then delete the old automatically created ones)

    Oh and i suspect your js will not be in a folder javascripts, so edit that to in the config.rb

    Anyway having done that(or not) you should then be able to run

    compass watch
    

    and all should be good , i.e. your scss files get compiled to css files

    As an alternative that I have not tried, but theoretically

    compass compile [path/to/scss]
    

    should work too, if you don't want to init compass

    More information to be found in the compass documentation here

    and to go completely over the top, if this is something you find yourself doing often, and hate the defaults then edit/add the following to your ~/.bash_profile

    alias compass_init="compass init --syntax=sass --css-dir=css --javascripts-dir=js"
    
    0 讨论(0)
  • 2020-12-29 05:52

    For anyone looking to compile SCSS without making a whole project (e.g., for a one-off page), you can just create a config.rb, but it needs at least two parameters: css_dir and sass_dir. (touch-ing it is not enough). A minimal config.rb:

    css_dir='.';sass_dir='.'
    

    This effectively creates a compass project for the purpose of compiling simple files. You'll have to include the rest of the params if you want to use sprites, etc. Assuming compass can write to the directory, it'll create the .sass-cache directory once you run compass compile or compass watch for the first time.

    It's also important to note that compass commands must be run from the directory with config.rb, or you'll get this error.

    Finally, if you just want to take advantage of simple SASS features (and not Compass framework components), straight SASS is often simpler:

    sass --watch foo.scss:foo.css

    0 讨论(0)
  • 2020-12-29 06:01

    Remove the "/" in front of your directory names.

    This error occurs when your source path is incorrect. In your case, your directories have an extra "/". Removing them should fix your problem.

    As others have said, creating a config.rb with compass init will fix it too.

    Note that Config.rb is not necessary when using Grunt or similar runners that run compass. That might be how your project was running before without the config.rb file. The runner starts compass with all the paths and options in Gruntfile.js. Having paths/options in both Gruntfile and config.rb might cause problems.

    0 讨论(0)
  • 2020-12-29 06:05

    I usually have my config.rb in my project directory (or root) rather than the sass directory.

    Folder structure would be like this:

    • config.rb
    • --- css
    • --- sass

    Also your css_dir and sass_dir have the same value, which could lead to your issue as well.

    0 讨论(0)
提交回复
热议问题