Package your Chrome Extensions in a bliss.
Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-crx
Then add this line to your project's grunt.js
gruntfile:
grunt.loadNpmTasks('grunt-crx');
This task is a [multi task][types_of_tasks], meaning that grunt will automatically iterate over all crx
targets if a target is not specified.
There will be as many extension packaged as there are targets.
src
(string, mandatory): location of a folder containing a Chrome Extensionmanifest.json
;dest
(string, mandatory): location of a folder where thecrx
file will be available;baseURL
(string): folder URL where package files will be self hosted (see Autoupdating in Chrome Extension docs);exclude
(array): array of glob stylesrc
-relative paths which won't be included in the built package;privateKey
(string): location of the.pem
file used to encrypt your extension;filename
(string|template pattern): filename of the package (likemyExtension.crx
) –manifest
attributes are injected from themanifest.json
;options
(object) – options that are directly provided to theChromeExtension
object;maxBuffer
(Number): amount of bytes available to package the extension (see child_process#exec)
privateKey
:key.pem
— which means the task will look forward its file next to thegrunt.js
one;filename
:<%= pkg.name %>-<%= manifest.version %>.crx
– which means it will automagically use yourpackage.json
name andmanifest.json
version to build the filename.
//grunt.js
grunt.loadNpmTasks('grunt-crx');
grunt.initConfig({
crx: {
myPublicPackage: {
"src": "src/",
"dest": "dist/crx/",
},
myHostedPackage: {
"src": "src-beta/",
"dest": "dist/crx-beta/src",
"baseURL": "http://my.app.net/beta-files/",
"exclude": [ ".git", ".svn" ],
"privateKey": "dist/crx-beta/key.pem",
"options": {
"maxBuffer": 3000 * 1024 //build extension with a weight up to 3MB
}
}
}
});
It is strongly recommended to store your privates keys outside the source folder of your extensions.
Otherwise we will laught at you.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
- added
exclude
property
Initial release.
Copyright (c) 2012 oncletom Licensed under the MIT license.