-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Problems caused by using alisaes and omitting file suffixes at the same time #3532
Comments
Well, though it is a bug, please be aware that:
|
okay, we have also taken note of the community's suggestions on the file suffixes. However, this usage has been widely used in many of our existing projects, so if we want to maintain the consistency of the projects, we have no choice but to omit the file suffix. In addition, since the community allows users to omit the file suffix, i think it is necessary to ensure the correctness of this function. |
你好,想问下这个问题现在有解决吗?我们也碰到了这个问题,我们是在vue2项目中使用,在老项目中有非常多类似 |
你好,想问下这个问题预计什么时候能修复呢? |
Hi @patak-js @nihalgonsalves , could you please review this PR #3534 , we have a lot of legacy projects which use @ alias and omit extensions. Thank you! |
A temporary workaround vite-plugin-resolve-extension-vue. // vite.config.js
import resolveExtensionVue from 'vite-plugin-resolve-extension-vue';
export default {
plugins: [resolveExtensionVue()],
}; |
Describe the bug
If a specific file suffix is added as the
resolve.extension
field, vite allows its users to ignore the file suffix. However, when the user ignores the file suffix and uses the alias (@
) to refer to a file in the project, an internal server error will occur. This error indicates that the file whose suffix is omitted does not exist. For example, if you add the.vue
field inresolve.extension
, you can omit the.vue
suffix when referencing avue
file. However, in the case where we use@/path
to refer to a file in the project, the project does not work properly. I will submit a PR to fix this problem!Reproduction
https://github.com/ygj6/vite-issue-investigative/tree/alias_bug
In the
main.js
file, if user usesimport App from '@/App'
to refer to the App.vue. An error appears which indicatesNo loader is configured for ".vue" files: src/App.vue
. However, there are two cases which can work as normal. For example,import App from './App
orimport App from '@/App.vue
.System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager:
Logs
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: