我只是在学习Grunt。我将使用 compass 来生成垂直节奏和图像精灵,并使用 autoprefixer 来为 css3 样式添加前缀。
这是我的Gruntfile.js。
module.exports = function(grunt) {
var globalConfig = {
sassDir: 'sass',
cssDir: 'css'
};
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Project configuration.
grunt.initConfig({
globalConfig: globalConfig,
pkg: grunt.file.readJSON('package.json'),
compass: {
dev: {
options: {
sassDir: '<%= globalConfig.sassDir %>',
cssDir: '<%= globalConfig.cssDir %>'
}
}
},
autoprefixer: {
dev: {
options: {
browsers: ['last 2 versions']
},
src: '<%= globalConfig.cssDir %>/style.css',
dest: '<%= globalConfig.cssDir %>/style.css'
}
},
watch: {
compass: {
files: ['<%= globalConfig.sassDir %>/**/*.scss'],
tasks: ['compass:dev'],
},
autoprefixer: {
files: ['<%= globalConfig.cssDir %>/style.css'],
tasks: ['autoprefixer:dev']
},
livereload: {
options: { livereload: true },
files: ['<%= globalConfig.cssDir %>/style.css']
}
}
});
// Default task(s) that will be run by invoking 'grunt' w/o args
grunt.registerTask('styles:dev', ['compass', 'autoprefixer']);
grunt.registerTask('default', ['styles:dev', 'watch']);
};
但每当我跑步
grunt
除了 grunt-contrib-watch 无休止地调用 grunt-autoprefixer 之外,一切都按预期工作。
我刚开始学习Grunt。这可能是我的Gruntfile.js上的错误配置
我希望你能在这里帮助我。