Gathering detailed insights and metrics for ajanuw-connect-livereload
Gathering detailed insights and metrics for ajanuw-connect-livereload
Gathering detailed insights and metrics for ajanuw-connect-livereload
Gathering detailed insights and metrics for ajanuw-connect-livereload
connect middleware for adding the livereload script to the response
npm install ajanuw-connect-livereload
Typescript
Module System
Node Version
NPM Version
TypeScript (99.56%)
Shell (0.44%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
124 Commits
2 Branches
1 Contributors
Updated on Jan 21, 2024
Latest Version
0.9.0
Package Id
ajanuw-connect-livereload@0.9.0
Unpacked Size
35.62 kB
Size
10.62 kB
File Count
19
NPM Version
6.14.13
Node Version
14.17.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Some codes have been modified, and some changes have taken place in the configuration. For details, please see
src/index.ts
orexamples/index.ts
$ npm install ajanuw-connect-livereload --save-dev
connect middleware for adding the livereload script to the response. no browser plugin is needed. if you are happy with a browser plugin, then you don't need this middleware.
1npm install connect-livereload --save-dev
note: if you use this middleware, you should make sure to switch off the Browser LiveReload Extension if you have it installed.
this middleware can be used with a LiveReload module e.g. grunt-contrib-connect or grunt-contrib-watch.
connect-livereload
itself does not serve the livereload.js
script.
In your connect or express application add this after the static and before the dynamic routes.
If you need liveReload on static html files, then place it before the static routes.
ignore
gives you the possibility to ignore certain files or url's from being handled by connect-livereload
.
1 app.use(require('connect-livereload')({ 2 port: 35729 3 }));
please see the examples for the app and Grunt configuration.
Options are not mandatory: app.use(require('connect-livereload')());
The Options have to be provided when the middleware is loaded:
e.g.:
app.use(require('connect-livereload')({
port: 35729,
ignore: ['.js', '.svg']
}));
These are the available options with the following defaults:
1 // `ignore` and `include`: array with strings and regex expressions elements. 2 // strings: included/ignored when the url contains this string 3 // regex: any expression: e.g. starts with pattern: /^.../ ends with pattern: /...$/ 4 ignore: [ 5 /\.js(\?.*)?$/, /\.css(\?.*)?$/, /\.svg(\?.*)?$/, /\.ico(\?.*)?$/, /\.woff(\?.*)?$/, 6 /\.png(\?.*)?$/, /\.jpg(\?.*)?$/, /\.jpeg(\?.*)?$/, /\.gif(\?.*)?$/, /\.pdf(\?.*)?$/ 7 ], 8 9 // include all urls by default 10 include: [/.*/], 11 12 // this function is used to determine if the content of `res.write` or `res.end` is html. 13 html: function (str) { 14 if (!str) return false; 15 return /<[:_-\w\s\!\/\=\"\']+>/i.test(str); 16 }, 17 18 // rules are provided to find the place where the snippet should be inserted. 19 // the main problem is that on the server side it can be tricky to determine if a string will be valid html on the client. 20 // the function `fn` of the first `match` is executed like this `body.replace(rule.match, rule.fn);` 21 // the function `fn` has got the arguments `fn(w, s)` where `w` is the matches string and `s` is the snippet. 22 rules: [{ 23 match: /<\/body>(?![\s\S]*<\/body>)/i, 24 fn: prepend 25 }, { 26 match: /<\/html>(?![\s\S]*<\/html>)/i, 27 fn: prepend 28 }, { 29 match: /<\!DOCTYPE.+?>/i, 30 fn: append 31 }], 32 33 // port where the script is loaded 34 port: 35729, 35 36 // location where the script is provided (not by connect-livereload). Change this e.g. when serving livereload with a proxy. 37 src: "http://localhost:35729/livereload.js?snipver=1", 38 39 // Set this option to `true` to set `req.headers['accept-encoding']` to 'identity' (disabling compression) 40 disableCompression: false, 41 42 // Locations where livereload plugins are provided (not by connect-livereload). 43 // These plugins should handle being loaded before _or_ after the livereload 44 // script itself (the order is not guaranteed), like 45 // https://github.com/mixmaxhq/livereload-require-js-includes/blob/5a431793d6fdfcf93d66814ddc58338515a3254f/index.js#L40-L45 46 plugins: [ 47 "http://localhost:3001/livereload-require-js-includes/index.js" 48 ]
please see the examples for the app and Grunt configuration.
The following example is from an actual Gruntfile that uses grunt-contrib-connect
1connect: { 2 options: { 3 port: 3000, 4 hostname: 'localhost' 5 }, 6 dev: { 7 options: { 8 middleware: function (connect) { 9 return [ 10 require('connect-livereload')(), // <--- here 11 checkForDownload, 12 mountFolder(connect, '.tmp'), 13 mountFolder(connect, 'app') 14 ]; 15 } 16 } 17 } 18}
For use as middleware in grunt simply add the following to the top of your array of middleware.
1 require('connect-livereload')(),
You can pass in options to this call if you do not want the defaults.
dev
is simply the name of the server being used with the task grunt connect:dev
. The other items in the middleware
array are all functions that either are of the form function (req, res, next)
like checkForDownload
or return that like mountFolder(connect, 'something')
.
An alternative would be to install the LiveReload browser plugin.
run the tests with
mocha
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More