File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
packages/create-vue-lib/src/template
playground/config/packages/playground
vitepress/config/packages/docs/.vitepress Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 1+ <% _ if (config .includeAtAliases ) { _% >
2+ import { relative , sep as pathSeparator } from ' node:path'
3+ < % _ } _%>
14import { fileURLToPath, URL } from 'node:url'
25
36import { defineConfig, type UserConfig } from 'vite'
@@ -28,10 +31,14 @@ export default defineConfig(({ mode }): UserConfig => ({
2831 find: ' @' ,
2932 replacement: ' @' ,
3033 customResolver (source , importer , options ) {
31- const filePath = source .replace (
32- / ^ @\/ / ,
33- importer? .startsWith (librarySrc) ? librarySrc : playgroundSrc
34- )
34+ let target = playgroundSrc
35+
36+ // If the importer is inside librarySrc we resolve @ to that path
37+ if (importer && relative (importer, librarySrc).split (pathSeparator).every (p => p === ' ..' )) {
38+ target = librarySrc
39+ }
40+
41+ const filePath = source .replace (/ ^ @\/ / , target)
3542
3643 return this .resolve (filePath, importer, options)
3744 }
Original file line number Diff line number Diff line change 1+ <% _ if (config .includeAtAliases ) { _% >
2+ import { relative , sep as pathSeparator } from ' node:path'
3+ < % _ } _%>
14import { fileURLToPath, URL } from 'node:url'
25
36import { defineConfigWithTheme } from 'vitepress'
@@ -50,10 +53,14 @@ export default ({ mode }: { mode: string }) => defineConfigWithTheme({
5053 find: ' @' ,
5154 replacement: ' @' ,
5255 customResolver (source , importer , options ) {
53- const filePath = source .replace (
54- / ^ @\/ / ,
55- importer? .startsWith (librarySrc) ? librarySrc : docsSrc
56- )
56+ let target = docsSrc
57+
58+ // If the importer is inside librarySrc we resolve @ to that path
59+ if (importer && relative (importer, librarySrc).split (pathSeparator).every (p => p === ' ..' )) {
60+ target = librarySrc
61+ }
62+
63+ const filePath = source .replace (/ ^ @\/ / , target)
5764
5865 return this .resolve (filePath, importer, options)
5966 }
You can’t perform that action at this time.
0 commit comments