Skip to content

Commit cb67f77

Browse files
authored
Merge pull request #28 from tartinesKiller/master
Add ability to specify lanIp argument (fix #27)
2 parents 3a958fd + 3420cd2 commit cb67f77

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
const {
22
info
33
} = require('@vue/cli-shared-utils')
4+
const address = require('address')
45

56
const defaults = {
67
mode: 'development',
78
host: '0.0.0.0',
89
port: 8080,
9-
https: false
10+
https: false,
11+
lanIp: address.ip()
1012
}
1113

1214
module.exports = (api, options) => {
13-
const address = require('address')
1415
const portfinder = require('portfinder')
1516

1617
api.registerCommand('cordova-serve', {
@@ -20,7 +21,8 @@ module.exports = (api, options) => {
2021
'--open': `open browser on server start`,
2122
'--host': `specify host (default: ${defaults.host})`,
2223
'--port': `specify port (default: ${defaults.port})`,
23-
'--https': `use https (default: ${defaults.https})`
24+
'--https': `use https (default: ${defaults.https})`,
25+
'--lan-ip': `IP of the machine running cordova-serve (default: ${defaults.lanIp})`
2426
}
2527
}, args => {
2628
const projectDevServerOptions = options.devServer || {}
@@ -31,7 +33,7 @@ module.exports = (api, options) => {
3133
host: args.host || process.env.HOST || projectDevServerOptions.host || defaults.host,
3234
port,
3335
https: args.https || projectDevServerOptions.https || defaults.https,
34-
lanIp: address.ip()
36+
lanIp: args['lan-ip'] || defaults.lanIp
3537
}
3638
const wwwDirPath = api.resolve('www')
3739
info('your www/index.html is overwrited.')

redirect.ejs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
var protocol = '<%- https ? "https" : "http" %>'
2020
var port = '<%- port %>'
2121
var platform = device.platform.toLowerCase()
22+
if (platform === 'amazon-fireos') { // see https://github.com/dekimasoon/vue-cli-plugin-cordova/issues/29
23+
// platform "amazon-fireos" seems to have disapear from Cordova docs, and can't be downloaded anymore.
24+
// In order to avoid asking server for something that doesn't exist, "alias" "amazon-fireos" to simply "android"
25+
platform = 'android'
26+
}
2227
var redirectTo = protocol + '://' + getRedirectIp(lanIp) + ':' + port + '/?_cp=' + platform
2328
window.location.href = redirectTo
2429
})

0 commit comments

Comments
 (0)