Vite config with absolute paths

Im trying to make an e2e test for my components and im using absolute paths like
import { component } from "~/shared/component/test";
import { component } from "~/shared/component/test";
On my vite config I have this alias
resolve: {
alias: {
"~": path.resolve(__dirname, "src"),
},
},
resolve: {
alias: {
"~": path.resolve(__dirname, "src"),
},
},
And yet while running the test for a specific component i'm getting an error related to this absolute paths
Error: [vite]: Rollup failed to resolve import "~/types/sidebar" from "src/shared/components/sidebar/Drawer.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
Error: [vite]: Rollup failed to resolve import "~/types/sidebar" from "src/shared/components/sidebar/Drawer.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
Any idea ?
1 Reply
Knox
Knox2y ago
Also added this
build: {
rollupOptions: {
external: [/^~/, "react", "react-dom"],
},
},
build: {
rollupOptions: {
external: [/^~/, "react", "react-dom"],
},
},
But doesn't change the error output
Want results from more Discord servers?
Add your server