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
6 changes: 4 additions & 2 deletions packages/@vue/cli-service/lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
hasProjectPnpm,
IpcMessenger
} = require('@vue/cli-shared-utils')
const getBaseUrl = require('../util/getBaseUrl')

const defaults = {
host: '0.0.0.0',
Expand All @@ -14,6 +15,7 @@ const defaults = {

/** @type {import('@vue/cli-service').ServicePlugin} */
module.exports = (api, options) => {
const baseUrl = getBaseUrl(options)
api.registerCommand('serve', {
description: 'start development server',
usage: 'vue-cli-service serve [options] [entry]',
Expand Down Expand Up @@ -116,7 +118,7 @@ module.exports = (api, options) => {
protocol,
host,
port,
isAbsoluteUrl(options.publicPath) ? '/' : options.publicPath
isAbsoluteUrl(baseUrl) ? '/' : baseUrl
)
const localUrlForBrowser = publicUrl || urls.localUrlForBrowser

Expand Down Expand Up @@ -187,7 +189,7 @@ module.exports = (api, options) => {
'text/html',
'application/xhtml+xml'
],
rewrites: genHistoryApiFallbackRewrites(options.publicPath, options.pages)
rewrites: genHistoryApiFallbackRewrites(baseUrl, options.pages)
},
hot: !isProduction
}, projectDevServerOptions, {
Expand Down
3 changes: 3 additions & 0 deletions packages/@vue/cli-service/lib/util/getBaseUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function getBaseUrl (options) {
return options.publicPath === 'auto' ? '' : options.publicPath
}
3 changes: 2 additions & 1 deletion packages/@vue/cli-service/lib/util/resolveClientEnv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const getBaseUrl = require('./getBaseUrl')
const prefixRE = /^VUE_APP_/

module.exports = function resolveClientEnv (options, raw) {
Expand All @@ -7,7 +8,7 @@ module.exports = function resolveClientEnv (options, raw) {
env[key] = process.env[key]
}
})
env.BASE_URL = options.publicPath
env.BASE_URL = getBaseUrl(options)

if (raw) {
return env
Expand Down