【发布时间】:2015-11-24 11:47:54
【问题描述】:
我对 Grunt、Compass 和 Sass 还很陌生。每当我对.scss 文件进行更改时,运行该任务需要将近 25 秒。我一定做错了什么。这是我的设置:
我的scss 部分是这样的:
_buttons.scss, _colors.scss, _typography.scss 等等。这些由_base.scss 文件导入。这又与compass 一起导入到我的main.scss 文件中。
我的gruntfile 看起来像这样:
module.exports = function( grunt ){
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.initConfig({
//UGLIFY
uglify:{
options: {
beautify:true
},//options
my_target: {
files:{
'js/main.js': ['_/js/partials/*.js']
}//files
}//my target
},//uglify
//COMPASS
compass: {
dev:{
options: {
config: 'config.rb'
}//options
}//development mode
},//compass
//WATCH
watch:{
options: {
livereload:true,
spawn: false
},
scripts: {
files: ['_/js/partials/*.js'],
tasks:['uglify']
},//scripts
sass: {
files: ['_/sass/**/*.scss'],
tasks: ['compass:dev']
},//sass
html: {
files: ['*.html']
},//html
}//watch
}),//init config
grunt.registerTask('default', 'watch')
}//exports
我读过的其他问题建议将 spawn 设置为 false(我认为无论如何都是默认设置),但这并没有什么区别。 uglify 任务只需要一两秒钟。那么我的 sass 文件出了什么问题?
更新
如果我运行grunt -verbose,这是输出:
看起来 Grunt 正在查看每个文件,而不仅仅是我指定的文件。即php目录。
【问题讨论】:
-
我不确定,但似乎
grunt-contrib-compass配置的示例与您的配置完全不同:github.com/gruntjs/grunt-contrib-compass#watch 值得一试吗? -
@TonyBarnes 好点,但是我试了一下,没有任何区别。我的指南针任务指向具有相同信息的 congif.rb 文件。
标签: sass gruntjs compass-sass compass