Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bootstrap-vue-3 resolver (#520)
- Loading branch information
1 parent
2a120ee
commit b58ed85
Showing
2 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { ComponentResolver } from '../../types' | ||
|
||
export interface BootstrapVue3ResolverOptions { | ||
/** | ||
* Auto import for directives. | ||
* | ||
* @default true | ||
*/ | ||
directives?: boolean | ||
} | ||
|
||
/** | ||
* Resolver for BootstrapVue | ||
* | ||
* @link https://github.com/cdmoro/bootstrap-vue-3 | ||
*/ | ||
export const BootstrapVue3Resolver = (_options: BootstrapVue3ResolverOptions = {}): Array<ComponentResolver> => { | ||
const options = { directives: true, ..._options } | ||
const resolvers: Array<ComponentResolver> = [{ | ||
type: 'component', | ||
resolve: (name) => { | ||
if (name.match(/^B[A-Z]/)) | ||
return { name, from: 'bootstrap-vue-3' } | ||
}, | ||
}] | ||
|
||
if (options.directives) { | ||
resolvers.push({ | ||
type: 'directive', | ||
resolve: (name) => { | ||
if (name.match(/^B[A-Z]/)) | ||
return { name: `V${name}`, from: 'bootstrap-vue-3' } | ||
}, | ||
}) | ||
} | ||
|
||
return resolvers | ||
} |
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