【发布时间】:2014-01-08 18:12:09
【问题描述】:
我已阅读 grunt、sass 和 compass 文档,但找不到太多关于此错误的信息。我还看到另一个人有类似的错误,但这是由于他们的 contrib.rb 文件中的语法问题,我不相信我的 contrib.rb 文件中有。
问题:我运行 grunt watch 任务并在任何时候对我的 sass (*.scss) 文件进行更改时出现错误。 错误内容如下:
NoMethodError on line 264 of /Library/Ruby/Gems/1.8/gems/compass-0.12.2/lib/compass/configuration/inheritance.rb: _
Run with --trace to see the full backtrace
因此,我的 sass 文件都没有处理到我的 css 文件夹。我是 grunt 的新手,诚然,我对我所做的大量初始设置感到有些不知所措。关于我的文件可能如何配置不正确,或者与 grunt 相关的 compass 或 sass 版本之一是否可能存在错误(都是最新的非 beta 版本),我很乐意提供任何建议。
这是我的 contrib.rb 文件的文本:
require "susy"
css_dir = _/css
sass_dir = _/components/sass
javascripts_dir = _/js
output_style = :compressed
我的 gruntfile.js :
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.initConfig({
uglify: {
my_target: {
files: {
'_/js/script.js': ['_/components/js/*.js'] //tells grunt to track and compress any .js file found in components/js folder
} //files
} // my_target
}, // uglify
compass: {
dev: {
options: {
config: 'config.rb',
force: true // <-- ???
} //options
} //dev
}, //compass
watch: {
options: { livereload: true },
scripts: {
files: ['_/components/js/*.js'],
tasks: ['uglify']
}, //scripts
sass: {
files: ['_/components/sass/*.scss'],
tasks: ['compass:dev']
}, //sass
html: {
files: ['*.html']
}
} // watch
})// initConfig
grunt.registerTask('default', 'watch'); //makes 'grunt' command automaticaly execute the watch command to monitor JS files
} //exports
还有我的项目文件夹结构:
sass_first_proj
|
_(folder)
|
components
|
css
|
js
images
node_modules
|
grunt
|
grunt-contrib-compass
|
grunt-contrib-uglify
|
grunt-contrib-watch
|
matchdep
.gitignore
|
config.rb
|
gruntfile.js
|
index.html
|
package.json
【问题讨论】:
-
你能运行
grunt compass还是得到同样的错误?我的猜测是问题根本不在于watch任务。 -
我在运行 grunt compass 时产生了同样的错误,但仍然无法让 css 文件链接到 scss 文件。
-
嗯...你可以直接从命令行运行
compass吗?我不确定你需要的论点到底是什么。但如果它也不能运行,那么 Grunt 可能根本就不是问题。 -
我能够从命令行运行 compass watch 任务而没有错误消息,但是当我切换到我的项目目录(上面显示为 sass_first_proj 的根文件夹)时,我再次生成了 NoMethodError。
-
我不是在谈论 Grunt 任务,我是在问您是否可以在 Grunt 之外从命令行运行
compass本身。我们需要将问题隔离到 compass 或 watch 任务。但有这样的错误,我猜这是指南针问题。
标签: css sass gruntjs compass-sass