Last active
January 1, 2016 17:18
-
-
Save DrewAPicture/8176014 to your computer and use it in GitHub Desktop.
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 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
// 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'] ); | |
}; |
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
{ | |
"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