【发布时间】:2013-12-30 03:24:36
【问题描述】:
您好,我是 grunt 的新手,在使用 compass 启动和运行它时遇到问题。
这是我的 Gruntfile:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
//Read the package.json (optional)
pkg: grunt.file.readJSON('package.json'),
// Metadata.
meta: {
sassPath: 'templates/sass/',
cssPath: 'public/css/',
},
// Task configuration.
compass: {
dist: {
files: {
'<%= meta.cssPath %>*.css': '<%= meta.sassPath %>**/*.scss'
}
}
},
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-compass');
// Default task.
grunt.registerTask('default', ['compass']);
}
但是当我运行 grunt --verbose 时,我得到了这个:
...
Running "default" task
Running "compass" task
Running "compass:dist" (compass) task
Verifying property compass.dist exists in config...OK
Files: templates/sass/ie.scss, templates/sass/print.scss, templates/sass/screen.scss, templates/sass/style.scss -> public/css/*.css
Options: (none)
Nothing to compile. If you're trying to start a new project, you have left off the directory argument.
Run "compass -h" to get help.
Done, without errors.
所以它看起来像是看到了文件,甚至看到了将它们放在哪里......出了什么问题?
编辑:让人们知道最终答案...我以为我以前尝试过这个但没有成功,但今天早上我最终让它工作了:
compass: {
dist: {
expand: true,
cwd: '<%= meta.scssPath %>',
src: ['{,*/}*.scss'],
dest: '<%= meta.cssPath %>',
ext: '.css'
}
},
编辑 2:好吧,我这辈子不知道为什么,但它只在 config.rb 存在时才有效......为什么 grunt 会使用 compass 配置是另一个问题......
【问题讨论】:
-
Grunt 不使用 Compass 配置,Compass 使用。 ;) Grunt 插件只是从 shell 运行
compass命令。
标签: gruntjs compass-sass