module.exports = function( grunt ) { // Project configuration grunt.initConfig( { pkg: grunt.file.readJSON( 'package.json' ), concat: { options: { stripBanners: true, banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + ' * <%= pkg.homepage %>\n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + ' * Licensed GPLv2+' + ' */\n' }, main: { src: [ 'assets/js/src/ascribe.js' ], dest: 'assets/js/ascribe.js' } }, jshint: { all: [ 'Gruntfile.js', 'assets/js/src/**/*.js', 'assets/js/test/**/*.js' ] }, uglify: { all: { files: { 'assets/js/ascribe.min.js': ['assets/js/ascribe.js'] }, options: { banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + ' * <%= pkg.homepage %>\n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + ' * Licensed GPLv2+' + ' */\n', mangle: { except: ['jQuery'] } } } }, sass: { all: { options: { precision: 2, sourceMap: true }, files: { 'assets/css/ascribe.css': 'assets/css/sass/ascribe.scss' } } }, postcss: { dist: { options: { processors: [ require('autoprefixer-core')({browsers: 'last 2 versions'}) ] }, files: { 'assets/css/ascribe.css': [ 'assets/css/ascribe.css' ] } } }, cssmin: { options: { banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' + ' * <%=pkg.homepage %>\n' + ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' + ' * Licensed GPLv2+' + ' */\n' }, minify: { expand: true, cwd: 'assets/css/', src: ['ascribe.css'], dest: 'assets/css/', ext: '.min.css' } }, watch: { livereload: { files: ['assets/css/*.css'], options: { livereload: true } }, styles: { files: ['assets/css/sass/**/*.scss'], tasks: ['sass', 'autoprefixer', 'cssmin'], options: { debounceDelay: 500 } }, scripts: { files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'], tasks: ['jshint', 'concat', 'uglify'], options: { debounceDelay: 500 } } }, clean: { main: ['release/<%= pkg.version %>'] }, copy: { // Copy the theme to a versioned release directory main: { src: [ '**', '!**/.*', '!**/readme.md', '!node_modules/**', '!vendor/**', '!tests/**', '!release/**', '!assets/css/sass/**', '!assets/css/src/**', '!assets/js/src/**', '!images/src/**', '!bootstrap.php', '!bower.json', '!composer.json', '!composer.lock', '!Gruntfile.js', '!package.json', '!phpunit.xml', '!phpunit.xml.dist' ], dest: 'release/<%= pkg.version %>/' } }, compress: { main: { options: { mode: 'zip', archive: './release/wptheme.<%= pkg.version %>.zip' }, expand: true, cwd: 'release/<%= pkg.version %>/', src: ['**/*'], dest: 'wptheme/' } }, phpunit: { classes: { dir: 'tests/phpunit/' }, options: { bin: 'vendor/bin/phpunit', bootstrap: 'bootstrap.php.dist', colors: true, testSuffix: 'Tests.php' } }, qunit: { all: ['tests/qunit/**/*.html'] } } ); // Load tasks require('load-grunt-tasks')(grunt); // Register tasks grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] ); grunt.registerTask( 'js', ['jshint', 'concat', 'uglify'] ); grunt.registerTask( 'default', ['css', 'js'] ); grunt.registerTask( 'build', ['default', 'clean', 'copy', 'compress'] ); grunt.registerTask( 'test', ['phpunit', 'qunit'] ); grunt.util.linefeed = '\n'; };