GruntFile returns [object, Object]

送分小仙女□ 提交于 2019-12-11 03:48:22

问题


I am using a foundation/jekyll boilerplate.

Whenever I run grunt, it only returns the following in my style.css

[object Object]

It should have processed the scss from the foundation files.

Here is the gruntfile.js

module.exports = function(grunt) {
  grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

sass: {
  options: {
    includePaths: ['bower_components/foundation/scss']
  },
  dist: {
    options: {
      outputStyle: 'compressed'
    },
    files: {
      'css/style.css': 'scss/style.scss'
    }        
  }
},

watch: {
  grunt: { files: ['Gruntfile.js'] },

  sass: {
    files: 'scss/**/*.scss',
    tasks: ['sass']
  }
}
  });

  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('build', ['sass']);
  grunt.registerTask('default', ['build','watch']);
}

The only thing I had to do was npm install node-sass. I ran grunt and the only code in my style.css was [object, Object]

edit: ran npm install grunt-sass, css now compiles nicely.


回答1:


It seems that there's an error with recent version of node-sass where in error situations node-sass pipes [object Object] instead of failing and showing a proper stacktrace.

Your Gruntfile worked fine for me in a reduced test case, so validate your scss files before running the task.

Also, update to the newest node-sass/grunt-sass with npm install node-sass -save-dev, as it doesn't seem to behave that way (but throws the proper error instead).



来源:https://stackoverflow.com/questions/29711385/gruntfile-returns-object-object

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