webext-buildtools-chrome-crx-builder
v1.0.18
Published
webext-buildtools builder for packing and signing Chrome Web Extension for offline distribution
Downloads
76
Maintainers
Readme
Introduction
webext-buildtools builder for packing and signing Chrome Web Extension for offline distribution built on base of crx package.
If you need a complete solution for Web Extension build/deploy, go to webext-buildtools-integrated-builder repo.
To read what are webext-buildtools and builders go to webext-buildtools-builder-types repo.
Installation
npm install webext-buildtools-chrome-crx-builder
Purpose
Builder allows you to build and sign your Web Extension for offline distribution. Read more details at Alternative Extension Distribution Options.
Usage example
const ChromeCrxBuilder = require('webext-buildtools-chrome-crx-builder').default;
const fs = require('fs-extra');
const options = { ... }; // see description below
const logMethod = console.log;
const builder = new ChromeCrxBuilder(options, logMethod);
// if you omit manifest it will be extracted from the zip buffer
builder.setInputManifest(await fs.readJson('./ext_dir/manifest.json'))
builder.setInputZipBuffer(await fs.readFile('./packed.zip'));
builder.requireCrxFile();
builder.requireUpdateXmlFile();
const buildResult = await builder.build();
Options
Options object described in declarations/options.d.ts
See how to get logMethod
for pretty output.
Inputs
setInputManifest(...)
. Object with parsed extension'spackage.json
. Required to produceupdate.xml
file. If omitted, will be extracted from zip buffer.setInputZipBuffer(...)
. Buffer with zipped extension dir. Required to produce packedcrx
file
You can use webext-buildtools-dir-reader-mw to generate needed inputs from extension directory.
Outputs
crx
packed and signed (using private key specified in options) crx file
Required options: privateKey
or privateKeyFilePath
, crxFilePath
for file
Require methods: requireCrxFile()
, requireCrxBuffer()
Assets:
const buffer = buildResult.getAssets().crxBuffer.getValue()
const crxFilePath = buildResult.getAssets().crxFile.getValue()
update.xml
updateXML for extensions hosted not on Chrome Web Store. This xml is used as response
at url, specified in manifest's update_url
key.
See https://developer.chrome.com/docs/apps/autoupdate/#update_url
for details.
Required options: updateXml.outFilePath
(for not temporary file), updateXml.codebaseUrl
Require methods: requireUpdateXmlFile()
, requireUpdateXmlBuffer()
Assets:
const buffer = buildResult.getAssets().updateXmlBuffer.getValue()
const xmlFilePath = buildResult.getAssets().updateXmlFile.getValue()