forked from mammadataei/cypress-vite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use vite-tsconfig-paths for resolving aliases (mammadataei#42)
- Loading branch information
1 parent
8194b41
commit 22c8d93
Showing
3 changed files
with
40 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
import { resolve } from 'path' | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
import { compilerOptions } from './tsconfig.json' | ||
|
||
function resolveAliasesFromTypescriptConfig() { | ||
return Object.entries(compilerOptions.paths).reduce((acc, [key, [value]]) => { | ||
const aliasKey = key.substring(0, key.length - 2) | ||
const path = value.substring(0, value.length - 2) | ||
return { ...acc, [aliasKey]: resolve(__dirname, path) } | ||
}, {}) | ||
} | ||
import tsconfigPaths from 'vite-tsconfig-paths' | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
alias: resolveAliasesFromTypescriptConfig(), | ||
}, | ||
plugins: [react()], | ||
plugins: [react(), tsconfigPaths()], | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.