Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture DrewAPicture/Gruntfile.js

Last active Jan 1, 2016
Embed
What would you like to do?
Grunt and package.json files for (in this example) packaging a theme for release. This should get you started -- plenty of Gruntjs resources out there.
// This assumes you've already installed Node.js and any related dependencies.
// 1. Drop this and package.json into your theme root
// 2. Run: npm install
// 3. Run: grunt
// 4. ??????
// 5. Profit
module.exports = function ( grunt ) {
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
copy: {
main: {
src: [
'**',
// Files marked with ! will be excluded from the copied and zipped files.
// !directoryname/** excludes the directory and everything in it.
'!.git',
'!.gitignore',
'!node_modules/**',
'!Gruntfile.js',
'!package.json',
'!release/**',
'!my-theme.zip'
],
dest: 'release/'
}
},
compress: {
main: {
options: {
mode: 'zip',
archive: './release.zip'
},
files: [{
src: ['./release/**']
}]
}
}
} );
// Load tasks
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-contrib-compress' );
// Default task.
grunt.registerTask( 'default', ['copy:main', 'compress:main'] );
};
{
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-compress": "~0.5.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.