Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
broccoli-serviceworker
Advanced tools
A broccoli plugin automating ServiceWorker file creation for Broccoli and Ember.js
ServiceWorker generator for Broccoli and Ember.js. Derived from broccoli-manifest.
For more details on ServiceWorker check out the following:
npm install --save-dev broccoli-serviceworker
//app/config/environment.js
ENV.serviceWorker = {
enabled: true,
serviceWorkerFile: "service-worker.js",
excludePaths: ['tests/', 'online.html',],
includePaths: ['/'],
fallback: [
'/online.html offline.html'
],
dynamicCache: [
'/api/todos'
]
};
Upgrade your index.html
(see below) and you are done.
The service worker bootstrap logic will be added to your index.html automatically, using contentFor hooks.
npm install --save broccoli-serviceworker
Use broccoli-serviceworker
as your last filter in the Brocfile.js
like this
var writeServiceWorker = require('broccoli-serviceworker');
...
var completeTree = mergeTrees([appJs, appCss, publicFiles]);
module.exports = mergeTrees([completeTree, writeServiceWorker((completeTree)]);
You can pass some options as the second argument to writeServiceWorker
:
writeServiceWorker(completeTree, {
serviceWorkerFile: "service-worker.js",
excludePaths: ['tests/', 'online.html',],
includePaths: ['/'],
fallback: [
'/online.html offline.html'
],
dynamicCache: [
'/api/todos'
],
skipWaiting: true
});
Files can be filtered using regular expressions.
{
excludePaths: ['index.html', new RegExp(/.\.map$/)],
includePaths: ['']
}
In order to use the generated serviceworker, you will need to register the serviceworker. This is done automatically if using as an Ember.js addon. If you're not using Ember.js, you can use the following code:
<!DOCTYPE html>
<html>
...
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./service-worker.js', {scope: './'})
.catch(function(error) {
alert('Error registering service worker:'+error);
});
} else {
alert('service worker not supported');
}
</script>
</html>
0.0.4 (2015-11-23)
Closed issues:
Merged pull requests:
FAQs
A broccoli plugin automating ServiceWorker file creation for Broccoli and Ember.js
The npm package broccoli-serviceworker receives a total of 2 weekly downloads. As such, broccoli-serviceworker popularity was classified as not popular.
We found that broccoli-serviceworker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.