local-domains
v1.2.4
Published
Returns a list of local domains
Downloads
10
Maintainers
Readme
local-domains
Returns a list of local domains
Install
With npm:
npm install --save-dev local-domains
Examples
const localDomains = require('localDomains');
localDomains('my-cool-site');
// => [
// 'my-cool-site.dev',
// 'my-cool-site.meh',
// '10.9.8.7.xip.io',
// 'my-cool-site.10.9.8.7.xip.io',
// 'www.my-cool-site.10.9.8.7.xip.io'
// ]
You can also pass an array
of wanted top level domains:
const localDomains = require('localDomains');
localDomains('my-cool-site', ['localdomain', 'thebest', 'xip']);
// => [
// 'my-cool-site.localdomain',
// 'my-cool-site.thebest',
// '10.9.8.7.xip.io'
// ]
This works great if you want to set the allowedHosts
in webpack:
const localDomains = require('localDomains');
const hostList = localDomains('my-cool-site');
…
devServer: {
allowedHosts: hostList,
compress: true,
host: '0.0.0.0',
hot: true,
inline: true,
port: 3000
}
…
or log out the places where you can access your dev server:
const localDomains = require('localDomains');
const hostList = localDomains('my-cool-site');
hostList.forEach(host => {
console.log(host);
});
API
localDomains(name, types)
Returns an array
of domains.
Parameter name
A required string
.
Parameter types
An optional array
of top level domains, with the default of ['dev', 'meh', 'xip', 'name.xip', www.name.xip]
. You can pass ['xip']
or ['xip.io']
and you will get [IP.xip.io]
.