问题
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