-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Description
Describe the bug
I added in vite.config.ts aliases list as follows
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
const aliases = {
apps: "/src/apps",
};
const aliasesList = [];
for (const [key, value] of Object.entries(aliases)) {
aliasesList.push({
find: key,
replacement: value,
});
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: aliasesList,
},
});Now when i try to make a dynamic import like this
import('apps/my-file').then(output => {
// works fine
});This works fine, but when i try to do something like this, it does not work at all
const path = 'my-file';
import('apps/' + path).then(output => {
// does not work
});See the example for reproducing.
Any idea on how to make this works.
Thanks
Reproduction
https://codesandbox.io/s/angry-snyder-7vsypo?file=/src/main.tsx
Steps to reproduce
No response
System Info
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 6.77 GB / 15.85 GB
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.18 - C:\Program Files\nodejs\yarn.CMD
npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (106.0.1370.42)
Internet Explorer: 11.0.19041.1566
npmPackages:
@vitejs/plugin-react: ^2.1.0 => 2.1.0
vite: ^3.1.0 => 3.1.8Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable