Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export default defineConfig(({ mode }): UserConfig => ({
{
find: '@',
replacement: '@',
customResolver(source, importer) {
return source.replace(
customResolver(source, importer, options) {
const filePath = source.replace(
/^@\//,
importer?.startsWith(librarySrc) ? librarySrc : playgroundSrc
)

return this.resolve(filePath, importer, options)
}
}, {
find: '<%- config.scopedPackageName %>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfigWithTheme } from 'vitepress'

<%_ if (config.includeAtAliases) { _%>
const librarySrc = fileURLToPath(new URL('../../<%- config.mainPackageDirName %>/src/', import.meta.url))
const playgroundSrc = fileURLToPath(new URL('../src/', import.meta.url))
const docsSrc = fileURLToPath(new URL('../src/', import.meta.url))
<%_ } _%>

export default ({ mode }: { mode: string }) => defineConfigWithTheme({
Expand Down Expand Up @@ -40,11 +40,13 @@ export default ({ mode }: { mode: string }) => defineConfigWithTheme({
{
find: '@',
replacement: '@',
customResolver(source, importer) {
return source.replace(
customResolver(source, importer, options) {
const filePath = source.replace(
/^@\//,
importer?.startsWith(librarySrc) ? librarySrc : playgroundSrc
importer?.startsWith(librarySrc) ? librarySrc : docsSrc
)

return this.resolve(filePath, importer, options)
}
}, {
find: '<%- config.scopedPackageName %>',
Expand Down