feat(cli): add skipInstall option

This commit is contained in:
陈嘉涵 2019-12-12 11:10:19 +08:00
parent 9155a7a491
commit 8e8892b323
4 changed files with 18 additions and 15 deletions

View File

@ -1,8 +1,13 @@
import Vue from 'vue'; import Vue from 'vue';
import Locale from '../../src/locale'; import Locale from '../../src/locale';
import Lazyload from '../../src/lazyload';
import { get } from '../../src/utils'; import { get } from '../../src/utils';
import { camelize } from '../../src/utils/format/string'; import { camelize } from '../../src/utils/format/string';
Vue.use(Lazyload, {
lazyComponent: true
});
// helper for demo locales // helper for demo locales
Vue.mixin({ Vue.mixin({
computed: { computed: {

View File

@ -1,12 +1,13 @@
import { get } from 'lodash';
import { join } from 'path'; import { join } from 'path';
import { pascalize, getComponents, smartOutputFile } from '../common'; import { pascalize, getComponents, smartOutputFile } from '../common';
import { SRC_DIR, PACKAGE_JSON } from '../common/constant'; import { SRC_DIR, PACKAGE_JSON, getVantConfig } from '../common/constant';
const version = process.env.PACKAGE_VERSION || PACKAGE_JSON.version; const version = process.env.PACKAGE_VERSION || PACKAGE_JSON.version;
type Options = { type Options = {
outputPath: string; outputPath: string;
pathResolver?: Function pathResolver?: Function;
}; };
function genImports(components: string[], options: Options): string { function genImports(components: string[], options: Options): string {
@ -27,8 +28,13 @@ function genExports(names: string[]): string {
} }
export function genPackageEntry(options: Options) { export function genPackageEntry(options: Options) {
const vantConfig = getVantConfig();
const components = getComponents(); const components = getComponents();
const names = components.map(item => pascalize(item)); const skipInstall = get(vantConfig, 'build.skipInstall', []);
const names = components
.filter(item => !skipInstall.includes(item))
.map(item => pascalize(item));
const content = `${genImports(components, options)} const content = `${genImports(components, options)}

View File

@ -1,25 +1,16 @@
<template> <template>
<demo-section> <demo-section>
<demo-block :title="$t('basicUsage')"> <demo-block :title="$t('basicUsage')">
<img <img v-for="img in imageList" v-lazy="img">
v-for="img in imageList"
v-lazy="img"
>
</demo-block> </demo-block>
<demo-block :title="$t('title2')"> <demo-block :title="$t('title2')">
<div <div v-for="img in backgroundImageList" v-lazy:background-image="img" />
v-for="img in backgroundImageList"
v-lazy:background-image="img"
/>
</demo-block> </demo-block>
<demo-block :title="$t('title3')"> <demo-block :title="$t('title3')">
<lazy-component> <lazy-component>
<img <img v-for="img in componentImageList" v-lazy="img">
v-for="img in componentImageList"
v-lazy="img"
>
</lazy-component> </lazy-component>
</demo-block> </demo-block>
</demo-section> </demo-section>

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
name: 'vant', name: 'vant',
build: { build: {
skipInstall: ['lazyload'],
site: { site: {
publicPath: 'vant/' publicPath: 'vant/'
} }