0
使用contrib-sass和contrib-watching我只想编译需要的文件,因为我在生产服务器上有很多scss文件。只编译需要的sass文件whit grunt
我写这个Gruntfile,但有些不起作用。看着作品,但没有编译。
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
sass: {
files: [
'sites/**/scss/*.scss'
],
tasks: ['sass'],
options: {
spawn: false
}
}
},
sass: {
dist:{
options: {
style: 'compressed'
},
files: objDestSource
}
}
});
// On watch events configure jshint:all to only run on changed file
grunt.event.on('watch', function(action, filepath) {
var filepath_scss = filepath;
var filepath_css = filepath.replace("scss", "css");
filepath_css = filepath_css.replace("scss", "css");
filepath= '\''+filepath_css+'\' : \''+filepath_scss+'\'';
console.log(filepath);
grunt.config('sass.dist.files', filepath);
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
};