2015-09-17 01:26:48 +02:00
|
|
|
module.exports = function( grunt ) {
|
|
|
|
|
|
|
|
// Project configuration
|
|
|
|
grunt.initConfig( {
|
|
|
|
pkg: grunt.file.readJSON( 'package.json' ),
|
|
|
|
concat: {
|
|
|
|
options: {
|
2015-09-17 02:17:28 +02:00
|
|
|
stripBanners: true,
|
|
|
|
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
|
|
|
|
' * <%= pkg.homepage %>\n' +
|
|
|
|
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
|
|
|
|
' * Licensed GPLv2+' +
|
|
|
|
' */\n'
|
2015-09-17 01:26:48 +02:00
|
|
|
},
|
|
|
|
main: {
|
|
|
|
src: [
|
2015-09-17 02:17:28 +02:00
|
|
|
'assets/js/src/ascribe.js'
|
2015-09-17 01:26:48 +02:00
|
|
|
],
|
2015-09-17 02:17:28 +02:00
|
|
|
dest: 'assets/js/ascribe.js'
|
2015-09-17 01:26:48 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
jshint: {
|
|
|
|
all: [
|
|
|
|
'Gruntfile.js',
|
|
|
|
'assets/js/src/**/*.js',
|
|
|
|
'assets/js/test/**/*.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
uglify: {
|
|
|
|
all: {
|
|
|
|
files: {
|
2015-09-17 02:17:28 +02:00
|
|
|
'assets/js/ascribe.min.js': ['assets/js/ascribe.js']
|
2015-09-17 01:26:48 +02:00
|
|
|
},
|
|
|
|
options: {
|
2015-09-17 02:17:28 +02:00
|
|
|
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
|
|
|
|
' * <%= pkg.homepage %>\n' +
|
|
|
|
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
|
|
|
|
' * Licensed GPLv2+' +
|
|
|
|
' */\n',
|
2015-09-17 01:26:48 +02:00
|
|
|
mangle: {
|
|
|
|
except: ['jQuery']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-09-17 02:17:28 +02:00
|
|
|
|
|
|
|
sass: {
|
|
|
|
all: {
|
|
|
|
options: {
|
|
|
|
precision: 2,
|
|
|
|
sourceMap: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
'assets/css/ascribe.css': 'assets/css/sass/ascribe.scss'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-09-17 01:26:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
postcss: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
processors: [
|
|
|
|
require('autoprefixer-core')({browsers: 'last 2 versions'})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
files: {
|
2015-09-17 02:17:28 +02:00
|
|
|
'assets/css/ascribe.css': [ 'assets/css/ascribe.css' ]
|
2015-09-17 01:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
cssmin: {
|
2015-09-17 02:17:28 +02:00
|
|
|
options: {
|
|
|
|
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
|
|
|
|
' * <%=pkg.homepage %>\n' +
|
|
|
|
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
|
|
|
|
' * Licensed GPLv2+' +
|
|
|
|
' */\n'
|
|
|
|
},
|
2015-09-17 01:26:48 +02:00
|
|
|
minify: {
|
|
|
|
expand: true,
|
|
|
|
|
|
|
|
cwd: 'assets/css/',
|
2015-09-17 02:17:28 +02:00
|
|
|
src: ['ascribe.css'],
|
2015-09-17 01:26:48 +02:00
|
|
|
|
|
|
|
dest: 'assets/css/',
|
|
|
|
ext: '.min.css'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
livereload: {
|
|
|
|
files: ['assets/css/*.css'],
|
|
|
|
options: {
|
|
|
|
livereload: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
styles: {
|
2015-09-17 02:17:28 +02:00
|
|
|
files: ['assets/css/sass/**/*.scss'],
|
|
|
|
tasks: ['sass', 'autoprefixer', 'cssmin'],
|
2015-09-17 01:26:48 +02:00
|
|
|
options: {
|
|
|
|
debounceDelay: 500
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scripts: {
|
|
|
|
files: ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'],
|
|
|
|
tasks: ['jshint', 'concat', 'uglify'],
|
|
|
|
options: {
|
|
|
|
debounceDelay: 500
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-09-17 02:17:28 +02:00
|
|
|
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']
|
|
|
|
}
|
2015-09-17 01:26:48 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
// Load tasks
|
|
|
|
require('load-grunt-tasks')(grunt);
|
|
|
|
|
|
|
|
// Register tasks
|
|
|
|
|
2015-09-17 02:17:28 +02:00
|
|
|
grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] );
|
|
|
|
|
|
|
|
|
|
|
|
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify'] );
|
2015-09-17 01:26:48 +02:00
|
|
|
|
2015-09-17 02:17:28 +02:00
|
|
|
grunt.registerTask( 'default', ['css', 'js'] );
|
2015-09-17 01:26:48 +02:00
|
|
|
|
2015-09-17 02:17:28 +02:00
|
|
|
grunt.registerTask( 'build', ['default', 'clean', 'copy', 'compress'] );
|
2015-09-17 01:26:48 +02:00
|
|
|
|
2015-09-17 02:17:28 +02:00
|
|
|
grunt.registerTask( 'test', ['phpunit', 'qunit'] );
|
2015-09-17 01:26:48 +02:00
|
|
|
|
|
|
|
grunt.util.linefeed = '\n';
|
|
|
|
};
|