How to use the workbox-build/package.json.version function in workbox-build

To help you get started, we’ve selected a few workbox-build examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BBVAEngineering / ember-cli-workbox / lib / broccoli-workbox.js View on Github external
BroccoliWorkbox.prototype.build = function() {
	const workboxOptions = Object.assign({}, this.workboxOptions);
	const directory = this.inputPaths[0];

	if (!this.options.enabled) {
		debug(yellow('Addon disabled. Generating empty service worker...'));
		workboxOptions.globPatterns = [];
		workboxOptions.runtimeCaching = [];
	}

	workboxOptions.globDirectory = path.join(directory, workboxOptions.globDirectory);
	workboxOptions.swDest = path.join(directory, workboxOptions.swDest);

	let cleanPromise = Promise.resolve();
	const workboxDirectory = path.join(directory, `workbox-v${workboxBuildPkg.version}`);

	// Remove workbox libraries directory to prevent exception on recopying it.
	if (!workboxOptions.importWorkboxFromCDN && fs.existsSync(workboxDirectory)) {
		cleanPromise = cleanDir(workboxDirectory);
	}
	const filesToIncludeInSW = glob.sync('assets/service-workers/*.js',
		{ cwd: workboxOptions.globDirectory }
	);

	workboxOptions.importScripts = filesToIncludeInSW;

	if (this.options.importScriptsTransform) {
		workboxOptions.importScripts = this.options.importScriptsTransform(workboxOptions.importScripts);
	}

	return cleanPromise.then(() =>

workbox-build

A module that integrates into your build process, helping you generate a manifest of local files that workbox-sw should precache.

MIT
Latest version published 10 days ago

Package Health Score

91 / 100
Full package analysis