How to implement Compass, Sass to a node.js project?

瘦欲@ 提交于 2020-01-16 18:37:14

问题


i have recently implemented the grunt task runner on my Node.js project and i'm using grunt-contrib-compass and grunt-contrib-watch in order to compile my sass and compass code through grunt whenever i make any changes.

My grunt file is like this:-

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        compass: {
            dist: {
                options: {
                    sassDir: 'public/sass',
                    cssDir: 'public/css'
                }
            }
        },
        watch: {
            css: {
                files: '**/*.scss',
                tasks: ['compass']
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default',['watch']);
}

I'm using windows and whenever i run grunt it watches for my sass files but whenever i make a change to these files i get this error:-

Warning: Couldn't find the 'compass.bat' binary. Make sure it's installed and in you $PATH Use --force to continue

I have installed ruby and compass through the ruby command prompt and the compass version is 1.0.3 and my gem installer version is 2.4.6. I have also tried including c:\Ruby200\bin to my Environmental variables and yes grunt-contrib-compass is installed in my Node.js project. I have tried everything, if anyone else has any experience in this i would love to hear from you. Thanks a lot.


回答1:


You just need to install Ruby and follow this steps:

  • npm install grunt-contrib-compass
  • Reinstall Ruby gem installer 1.9.3 with checked all checkbox
  • On ruby console - gem install sass
  • On ruby console - gem install compass


来源:https://stackoverflow.com/questions/30017488/how-to-implement-compass-sass-to-a-node-js-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!