JavaScript
0
Вклад в тег
module.exports = function(grunt) {
var lessFolderPath = 'Less';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
options: {
paths: ['Less/']
},
files: {
expand: true,
cwd: lessFolderPath + '/',
dest: "Modules/",
src: "*.less",
ext: ".css"
}
},
autoprefixer:{
options: {
browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'],
cascade: false
},
multiple_files: {
expand: true,
flatten: true,
cwd: 'Modules/',
src: '*.css',
dest: 'Modules/'
}
},
watch: {
less: {
files: ['Less/*.less'],
tasks: ['less', 'apr'],
options: {
spawn: false
}
}
}
});
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch:less', 'watch:css']);
grunt.registerTask('apr', ['autoprefixer']);
grunt.event.on('watch', function(action, filepath, target) {
var filePathName = filepath.replace(lessFolderPath + '\\','');
var fileName = filePathName.replace('.less','');
grunt.log.writeln(target + ': ' + filePathName + ' has ' + action);
grunt.config('autoprefixer.multiple_files.src', [fileName + '.css']);
grunt.config('less.files.src', [filePathName]);
});
};