Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User option 'baseUrl' is forced with a leading slash even for absolute URL #1084

Closed
guangyao-liu opened this issue Apr 6, 2018 · 2 comments · Fixed by #1172
Closed

User option 'baseUrl' is forced with a leading slash even for absolute URL #1084

guangyao-liu opened this issue Apr 6, 2018 · 2 comments · Fixed by #1172
Labels

Comments

@guangyao-liu
Copy link

Version

3.0.0-beta.6

Reproduction link

ensureSlash(resolved, 'baseUrl')

Steps to reproduce

  1. Setup the vue.config.js with following content:
module.exports = {
  baseUrl: 'https://cdn.example.com/assets/'
}
  1. Run npm run build
  2. Check the generated file at dist/index.html

What is expected?

<script type=text/javascript src=https://cdn.example.com/assets/js/app.8cd3ebbc.js></script>

What is actually happening?

<script type=text/javascript src=/https://cdn.example.com/assets/js/app.8cd3ebbc.js></script>
@yyx990803 yyx990803 added the bug label Apr 6, 2018
@mikekidder
Copy link

A possible workaround, by also setting publicPath:

// vue.config.js
var path = process.env.NODE_ENV === 'production' ? 'https://cdn.example.com/assets/' : '/'

module.exports = {
  configureWebpack: {
    output: {
      publicPath: path
    }
  }, 
  baseUrl: path
}

but also had to set in package.json:

  "scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "cross-env NODE_ENV=production vue-cli-service build"
  },

this did not work per docs:

  "scripts": {
    "serve": "vue-cli-service serve --open",
    "build": "vue-cli-service build --mode production"
  },

@guangyao-liu
Copy link
Author

My current workaround, btw, is

let baseUrl = '/';
if (process.env.NODE_ENV === 'production') {
    baseUrl = '//cdn.example.com/assets/';
}

module.exports = {
  baseUrl
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants