diff --git a/packages/@vue/cli-service/lib/commands/serve.js b/packages/@vue/cli-service/lib/commands/serve.js index 6ed4ee8b2c..cc66855e8b 100644 --- a/packages/@vue/cli-service/lib/commands/serve.js +++ b/packages/@vue/cli-service/lib/commands/serve.js @@ -5,6 +5,7 @@ const { hasProjectPnpm, IpcMessenger } = require('@vue/cli-shared-utils') +const getBaseUrl = require('../util/getBaseUrl') const defaults = { host: '0.0.0.0', @@ -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]', @@ -116,7 +118,7 @@ module.exports = (api, options) => { protocol, host, port, - isAbsoluteUrl(options.publicPath) ? '/' : options.publicPath + isAbsoluteUrl(baseUrl) ? '/' : baseUrl ) const localUrlForBrowser = publicUrl || urls.localUrlForBrowser @@ -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, { diff --git a/packages/@vue/cli-service/lib/util/getBaseUrl.js b/packages/@vue/cli-service/lib/util/getBaseUrl.js new file mode 100644 index 0000000000..e8b4497229 --- /dev/null +++ b/packages/@vue/cli-service/lib/util/getBaseUrl.js @@ -0,0 +1,3 @@ +module.exports = function getBaseUrl (options) { + return options.publicPath === 'auto' ? '' : options.publicPath +} diff --git a/packages/@vue/cli-service/lib/util/resolveClientEnv.js b/packages/@vue/cli-service/lib/util/resolveClientEnv.js index 2aa83f1554..dd4a7e2d56 100644 --- a/packages/@vue/cli-service/lib/util/resolveClientEnv.js +++ b/packages/@vue/cli-service/lib/util/resolveClientEnv.js @@ -1,3 +1,4 @@ +const getBaseUrl = require('./getBaseUrl') const prefixRE = /^VUE_APP_/ module.exports = function resolveClientEnv (options, raw) { @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy