Skip to content

Instantly share code, notes, and snippets.

@beshur
Last active April 20, 2018 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beshur/e7f3d5ab37a2905946be6917baa5f96e to your computer and use it in GitHub Desktop.
Save beshur/e7f3d5ab37a2905946be6917baa5f96e to your computer and use it in GitHub Desktop.
Chrome Extension Grunt Build Script

== Chrome Extension Grunt Build Script

Gruntfile that builds your extension, archives it and puts in the /builds folder. Also can bump up manifest and package.json files and tag release.

// Task configurations
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('manifest.json'),
bumpup: {
options: {
updateProps: {
pkg: 'manifest.json'
}
},
files: ['manifest.json', 'package.json']
},
tagrelease: '<%= pkg.version %>',
zip: {
'long-format': {
src: ['img/**', '*.js*','*.md','LICENSE', '!Gruntfile.js', '!package.json'],
dest: 'builds/<%= pkg.name + "-" + pkg.version %>.zip'
}
}
});
// Loading the plugins
grunt.loadNpmTasks('grunt-bumpup');
grunt.loadNpmTasks('grunt-tagrelease');
grunt.loadNpmTasks('grunt-zip');
// Alias task for release
grunt.registerTask('makeRelease', function (type) {
type = type ? type : 'patch'; // Default release type
grunt.task.run('bumpup:' + type); // Bump up the version
grunt.task.run('tagrelease'); // Commit & tag the release
grunt.task.run('zip'); // Compress an archive
});
grunt.registerTask('default', []);
grunt.registerTask('build', ['makeRelease']);
grunt.registerTask('pack', ['zip']);
}
{
"name": "chrome-ext-pics-build",
"version": "1.0.0",
"author": "Alex Buznik",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-cli": "*",
"grunt-bumpup": "*",
"grunt-release": "*",
"grunt-tagrelease": "*",
"grunt-zip": "*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment