⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.
Describe the bug
The base option currently does not support the ability to specify external URLs when serving content through the development server. This greatly limits the incorporation of Vite into other backends (Laravel, etc.) as static assets can no longer be served since the assets are served on a different port than the web server. I explored this specific problem in more depth in a separate issue by attempting to integrate Vite into a Laravel project.
As a solution suggestion, I believe that this issue would be solved best by implementing an environment variable to specify a URL base for content served specifically through the dev server. This would resolve these issues with backend compatibility and allow for the most flexability in users' dev environments.
Reproduction
I'm not sure how worthwhile a reproduction guide is for this issue, but this should give you something to compare against.
- Create a
vue-ts project using the @vitejs/app init script
npm init @vitejs/app
# Project name: vite-static-assets
# Select a template: vue-ts
cd vite-static-assets
npm install
- Set base property in
vite.config.ts:
export default defineConfig({
base: "http://localhost:3000/",
server: {
port: 3000 // Use the same port for dev and serve
},
// ...
})
- Compare the URL of the Vue logo in the inspector window between content served via
npm run dev and npm run build && npm run serve. The src attribute of the <img> tag will only contain the base of http://localhost:3000/ on production builds.
System Info
vite version: 2.0.1
- Operating System:
Ubuntu 20.10
- Node version:
14.15.4
- Package manager (npm/yarn/pnpm) and version:
npm
Logs (Optional if provided reproduction)
N/A
Describe the bug
The
baseoption currently does not support the ability to specify external URLs when serving content through the development server. This greatly limits the incorporation of Vite into other backends (Laravel, etc.) as static assets can no longer be served since the assets are served on a different port than the web server. I explored this specific problem in more depth in a separate issue by attempting to integrate Vite into a Laravel project.As a solution suggestion, I believe that this issue would be solved best by implementing an environment variable to specify a URL
basefor content served specifically through the dev server. This would resolve these issues with backend compatibility and allow for the most flexability in users' dev environments.Reproduction
I'm not sure how worthwhile a reproduction guide is for this issue, but this should give you something to compare against.
vue-tsproject using the@vitejs/appinit scriptnpm init @vitejs/app # Project name: vite-static-assets # Select a template: vue-ts cd vite-static-assets npm installvite.config.ts:npm run devandnpm run build && npm run serve. Thesrcattribute of the<img>tag will only contain the base ofhttp://localhost:3000/on production builds.System Info
viteversion:2.0.1Ubuntu 20.1014.15.4npmLogs (Optional if provided reproduction)
N/A