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
Add baseUrl option in vue-cli-service build command #1623
Comments
Agree. Or just use a relative path for the src URL so that it can also support preview the HTML in anyone's local browser: When run vue build get <script src=js/app.e46b869a.js></script> instead of <script src=/js/app.e46b869a.js></script> |
My bad. It can be resolved with module.exports = {
baseUrl: './'
} @ThibaudCrespin I guess you can solve your issue with this one as well. |
Hi, I am using This is making webpack put all dependencies (js/css/sourceMaps) at the root of the dist directory. Is this the intended behavior? I was expecting having my js assets inside a This is the content of my This is the content of my index.html after building for production: am I missing something here? Thanks! |
I'm not sure if it's a bug or intended. The path prefix will be eliminated if if (
placeAtRootIfRelative &&
!(/^https?:/.test(options.baseUrl)) &&
options.baseUrl.charAt(0) !== '/'
) {
return filePath.replace(/^\w+\//, '')
}
return options.assetsDir
? path.posix.join(options.assetsDir, filePath)
: filePath The return filePath.replace(/^\w+//, '') will remove the leading 'js' or 'css' |
I am using the latest version and it still doesn't work. When I set the baseUrl to './' it will be ignored. |
Can you try with this in
|
Didn't help. No change. |
is there any lead to solve this bug ? |
Same issue. Having to manually run a find & replace. |
I am still facing the issue. I have used below code to remove '/' and made my application workable.
With the above code, My application is running but some of css and js files are not getting the correct relative path for production build. |
May I know where to use this configuration? can you please give in detail code for the same (I mean, dir-->filename --> objName. etc ) |
IMHO it's just wrong and unnecessary that vue build defaults to |
Not sure if this is applicable to what is being discussed, but a valid URL would not be able to start with a dot. A dot would be valid for a file system, but a web server does not have a file system - it has URL's. / merely points to whatever is defined on the server as the root context - it most certainly does not point to a root directory of a drive. . (dot) does not point to anything on a web server (for all the web servers I have ever worked with anyway, and that is pretty much most of them) and is probably just being ignored or causing errors that result in what you think you want. |
vue.config.js
|
I am still facing same issue, any solution? |
I had the same issue, so i made a Python Script that calls: INDEX_PATH = DIST_PATH + "/index.html"
with open(INDEX_PATH, "r") as file:
content = file.read()
content = re.sub(r"href=([a-zA-Z\.]+)", r"href=./\1", content)
content = re.sub(r"src=([a-zA-Z\.]+)", r"src=./\1", content)
with open(INDEX_PATH, "w") as file:
file.write(content) (it just adds |
Under the newest version, configuring the
|
@cpury I ran into the same problem and found your post After searching a bit more I found out that |
@vue/cli 4.1.2
module.exports = {
publicPath: './',
}; <!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<meta http-equiv=X-UA-Compatible content="IE=edge">
<meta name=viewport content="width=device-width,initial-scale=1">
<link rel=icon href=icon.png>
<title>X</title>
<link href=js/about.c8f61e7c.js rel=prefetch>
<link href=css/app.a2b64800.css rel=preload as=style>
<link href=js/app.fe175e7f.js rel=preload as=script>
<link href=js/chunk-vendors.99d4a91b.js rel=preload as=script>
<link href=css/app.a2b64800.css rel=stylesheet>
</head>
<body>
<noscript><strong>We're sorry but X doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id=app></div>
<script src=js/chunk-vendors.99d4a91b.js></script>
<script src=js/app.fe175e7f.js></script>
</body>
</html> |
for me, baseUrl is not allowed and publicPath is not respected, |
For anyone coming across this in the future, I was able to use module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '././' : './',
}; <script src="./js/chunk-vendors.82980510.js"> Edit: added node env check so it can build for development too |
@thefyrewire Thanks man, that solved my problem with electron. |
In case anyone uses
|
What problem does this feature solve?
When you deploy on gh-pages, the base url is not the good one, it takes the root, not the repository. So I suggest to add on option to the cli command that will simply change relative urls in the vue application.
What does the proposed API look like?
vue-cli-service build --baseUrl
The text was updated successfully, but these errors were encountered: