Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const {
info
} = require('@vue/cli-shared-utils')
const address = require('address')

const defaults = {
mode: 'development',
host: '0.0.0.0',
port: 8080,
https: false
https: false,
lanIp: address.ip()
}

module.exports = (api, options) => {
const address = require('address')
const portfinder = require('portfinder')

api.registerCommand('cordova-serve', {
Expand All @@ -20,7 +21,8 @@ module.exports = (api, options) => {
'--open': `open browser on server start`,
'--host': `specify host (default: ${defaults.host})`,
'--port': `specify port (default: ${defaults.port})`,
'--https': `use https (default: ${defaults.https})`
'--https': `use https (default: ${defaults.https})`,
'--lan-ip': `IP of the machine running cordova-serve (default: ${defaults.lanIp})`
}
}, args => {
const projectDevServerOptions = options.devServer || {}
Expand All @@ -31,7 +33,7 @@ module.exports = (api, options) => {
host: args.host || process.env.HOST || projectDevServerOptions.host || defaults.host,
port,
https: args.https || projectDevServerOptions.https || defaults.https,
lanIp: address.ip()
lanIp: args['lan-ip'] || defaults.lanIp
}
const wwwDirPath = api.resolve('www')
info('your www/index.html is overwrited.')
Expand Down
5 changes: 5 additions & 0 deletions redirect.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
var protocol = '<%- https ? "https" : "http" %>'
var port = '<%- port %>'
var platform = device.platform.toLowerCase()
if (platform === 'amazon-fireos') { // see https://github.com/dekimasoon/vue-cli-plugin-cordova/issues/29
// platform "amazon-fireos" seems to have disapear from Cordova docs, and can't be downloaded anymore.
// In order to avoid asking server for something that doesn't exist, "alias" "amazon-fireos" to simply "android"
platform = 'android'
}
var redirectTo = protocol + '://' + getRedirectIp(lanIp) + ':' + port + '/?_cp=' + platform
window.location.href = redirectTo
})
Expand Down