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

base support for 'DEV' env or we can choose whether to use absolute path in dev mode #2542

Closed
suanmei opened this issue Mar 16, 2021 · 2 comments

Comments

@suanmei
Copy link

suanmei commented Mar 16, 2021

Is your feature request related to a problem? Please describe.
With the help of egg-view-static in midway/egg ,ctx.render my server's HTML template。For example,midway create a server on port 6001, vite create a server on port 3000, in HTML Template, load js file as

<!-- if development -->
<script type="module" src="http://localhost:3000/@vite/client"></script>
<script type="module" src="http://localhost:3000/main.js"></script>

There is no problem.

but if I import jpg in tsx file, the asset url in js is /assets/xxx.png. The page will try to load localhost:6001/assets/xxx.png instead of localhost:3000/assets/xxx.png

Describe the solution you'd like
Add a configuration item, we can choose whether to use absolute path(include localhost:3000) in development mode, rather than relative path

Describe alternatives you've considered
base support for 'DEV' env

@leevigraham
Copy link

Related: #1539

@yyx990803
Copy link
Member

The docs already mentioned it: add an egg middleware to serve static assets from your vite directory.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants