mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): package entry fit Vue 3
This commit is contained in:
parent
5cacc0df0c
commit
17379286c8
@ -15,7 +15,7 @@ type Options = {
|
|||||||
|
|
||||||
function genImports(components: string[], options: Options): string {
|
function genImports(components: string[], options: Options): string {
|
||||||
return components
|
return components
|
||||||
.map(name => {
|
.map((name) => {
|
||||||
let path = join(SRC_DIR, name);
|
let path = join(SRC_DIR, name);
|
||||||
if (options.pathResolver) {
|
if (options.pathResolver) {
|
||||||
path = options.pathResolver(path);
|
path = options.pathResolver(path);
|
||||||
@ -27,7 +27,7 @@ function genImports(components: string[], options: Options): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function genExports(names: string[]): string {
|
function genExports(names: string[]): string {
|
||||||
return names.map(name => `${name}`).join(',\n ');
|
return names.map((name) => `${name}`).join(',\n ');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genPackageEntry(options: Options) {
|
export function genPackageEntry(options: Options) {
|
||||||
@ -41,24 +41,20 @@ export function genPackageEntry(options: Options) {
|
|||||||
|
|
||||||
const version = '${version}';
|
const version = '${version}';
|
||||||
|
|
||||||
function install(Vue) {
|
function install(app) {
|
||||||
const components = [
|
const components = [
|
||||||
${components.filter(item => !skipInstall.includes(item)).join(',\n ')}
|
${components.filter((item) => !skipInstall.includes(item)).join(',\n ')}
|
||||||
];
|
];
|
||||||
|
|
||||||
components.forEach(item => {
|
components.forEach(item => {
|
||||||
if (item.install) {
|
if (item.install) {
|
||||||
Vue.use(item);
|
app.use(item);
|
||||||
} else if (item.name) {
|
} else if (item.name) {
|
||||||
Vue.component(item.name, item);
|
app.component(item.name, item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined' && window.Vue) {
|
|
||||||
install(window.Vue);
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
install,
|
install,
|
||||||
version,
|
version,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user