Hi, I'm trying to configure vite path alias. So the imports in ./load-context are configured correctly.
I've tried adding path alias, but it doesn't seem to be working and npm run dev fails with Cannot find package '~' imported
Here is my vite.config.ts
import { getLoadContext } from "./load-context";
import path from 'path';
export default defineConfig({
resolve: {
alias: {
'~/': path.resolve(__dirname, './app/'),
},
},
plugins: [Inspect(), remixCloudflareDevProxy({ getLoadContext }), mdx({
remarkPlugins: [
remarkFrontmatter,
remarkMdxFrontmatter,
],
}), remix(), tsconfigPaths()],
server: {
port: 3000,
fs: {
// Restrict files that could be served by Vite's dev server. Accessing
// files outside this directory list that aren't imported from an allowed
// file will result in a 403. Both directories and files can be provided.
// If you're comfortable with Vite's dev server making any file within the
// project root available, you can remove this option. See more:
// https://vitejs.dev/config/server-options.html#server-fs-allow
allow: ["app"],
},
},
});
The paths in my tsconfig.json
"paths": { "~/*": ["./app/*"] },