Created
December 12, 2013 14:28
-
-
Save IOZ/7928727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
//описываем конфигурацию | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), //подгружаем package.json, чтобы использовать его данные | |
/*jshint: { // описываем как будет проверять наш код - jsHint | |
options: { | |
curly: true, | |
eqeqeq: true, | |
immed: true, | |
latedef: true, | |
newcap: true, | |
noarg: true, | |
sub: true, | |
undef: true, | |
eqnull: true, | |
browser: true, | |
globals: { | |
jQuery: true, | |
$: true, | |
console: true | |
} | |
}, | |
'<%= pkg.name %>': { //вставляем название проекта из package.json | |
src: [ 'js/*.js' ] //какие файлы надо проверять | |
} | |
},*/ | |
validation: { | |
options: { | |
doctype: 'HTML5', | |
stoponerror: false | |
}, | |
your_target: { | |
src: ['*.html'] | |
} | |
}, | |
concat: { //описываем работу плагина конкатенации | |
dist: { | |
src: ['js/plugins.js', 'js/main.js'], // какие файлы конкатенировать | |
dest: 'js/build.js' // куда класть файл, который получиться после процесса конкатенации | |
} | |
}, | |
uglify: { //описываем работу плагина минификации js - uglify. | |
options: { | |
stripBanners: true, | |
banner: '/* <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' //комментарий который будет в минифицированном файле. | |
}, | |
build: { | |
src: 'js/build.js', // какой файл минифицировать | |
dest: 'js/build.min.js' // куда класть файл, который получиться после процесса минификации | |
} | |
}, | |
autoprefixer: { | |
options: { | |
browsers: ['last 2 version'] | |
}, | |
multiple_files: { | |
expand: true, | |
flatten: true, | |
src: 'css/main.css', // -> src/css/file1.css, src/css/file2.css | |
dest: 'css/' // -> dest/css/file1.css, dest/css/file2.css | |
} | |
}, | |
cssmin: { //описываем работу плагина минификации и конкатенации css. | |
with_banner: { | |
options: { | |
banner: '/* My minified CSS <%= grunt.template.today("yyyy-mm-dd") %> */' //комментарий который будет в output файле. | |
}, | |
files: { | |
'css/style.min.css' : ['css/*.css'] // первая строка - output файл. массив из строк, какие файлы конкатенировать и минифицировать. | |
} | |
} | |
}, | |
imagemin: { | |
dynamic: { // Another target | |
files: [{ | |
expand: true, // Enable dynamic expansion | |
cwd: 'img/', // Src matches are relative to this path | |
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match | |
dest: 'img/min/' // Destination path prefix | |
}] | |
} | |
} | |
/* | |
watch: { //описываем работу плагина слежки за файлами. | |
scripts: { | |
files: ['js/*.js'], //следить за всеми js файлами в папке src | |
tasks: ['jshint', 'concat', 'uglify', 'removelogging'] //при их изменении запускать следующие задачи | |
}, | |
css: { | |
files: ['css/*.css'], //следить за всеми css файлами в папке src | |
tasks: ['cssmin'] //при их изменении запускать следующую задачу | |
} | |
} | |
*/ | |
}); | |
//подгружаем необходимые плагины | |
//grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
//grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-html-validation'); | |
grunt.loadNpmTasks('grunt-autoprefixer'); | |
grunt.loadNpmTasks('grunt-contrib-csslint'); | |
//регистрируем задачу | |
grunt.registerTask('default', ['imagemin', 'autoprefixer', 'validation', 'autoprefixer', 'concat', 'uglify', 'cssmin']); //задача по умолчанию, просто grunt | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment