[Build] dynamic import (#1168)

This commit is contained in:
neverland 2018-05-27 12:01:21 +08:00 committed by GitHub
parent a5413aebfa
commit ea8d325c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 236 additions and 230 deletions

View File

@ -1,5 +1,6 @@
{
"presets": [
"stage-0",
[
"env",
{
@ -9,10 +10,11 @@
}
]
],
"plugins": ["transform-runtime", "transform-object-rest-spread"],
"plugins": ["transform-runtime"],
"env": {
"commonjs": {
"presets": [
"stage-0",
[
"env",
{

View File

@ -55,10 +55,10 @@ function buildDemoEntry() {
const dir = path.join(__dirname, '../../packages');
const demos = fs.readdirSync(dir)
.filter(name => fs.existsSync(path.join(dir, `${name}/demo/index.vue`)))
.map(name => `'${name}': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/${name}/demo'), '${name}')), '${name}'))`);
.map(name => `'${name}': () => wrapper(import('../../packages/${name}/demo'), '${name}')`);
const content = `${tips}
import { asyncWrapper, componentWrapper } from './demo-common';
import { wrapper } from './demo-common';
export default {
${demos.join(',\n ')}
@ -79,23 +79,10 @@ function buildDocsEntry() {
])
.map(fullPath => {
const name = getName(fullPath);
return `'${name}': wrapper(r => require.ensure([], () => r(require('${path.relative(join('docs/src'), fullPath)}')), '${name}'))`;
return `'${name}': () => import('${path.relative(join('docs/src'), fullPath)}')`;
});
const content = `${tips}
import progress from 'nprogress';
function wrapper(component) {
return function(r) {
progress.start();
component(r).then(() => {
progress.done();
}).catch(() => {
progress.done();
});
};
}
export default {
${docs.join(',\n ')}
};

View File

@ -3,7 +3,6 @@
*/
import Vue from 'vue';
import progress from 'nprogress';
import i18n from '../../packages/mixins/i18n';
import Vant, { Lazyload } from '../../packages';
import VantDoc, { DemoBlock, DemoSection } from 'vant-doc';
@ -85,29 +84,20 @@ Locale.add({
}
});
export function asyncWrapper(component) {
return function(r) {
progress.start();
component(r).then(() => {
progress.done();
}).catch(() => {
progress.done();
});
};
}
export function componentWrapper(component, name) {
component = component.default;
name = 'demo-' + name;
component.name = name;
const { i18n } = component;
if (i18n) {
const formattedI18n = {};
const camelizedName = camelize(name);
Object.keys(i18n).forEach(key => {
formattedI18n[key] = { [camelizedName]: i18n[key] };
});
Locale.add(formattedI18n);
}
return component;
export function wrapper(promise, name) {
return promise.then(component => {
component = component.default;
name = 'demo-' + name;
component.name = name;
const { i18n } = component;
if (i18n) {
const formattedI18n = {};
const camelizedName = camelize(name);
Object.keys(i18n).forEach(key => {
formattedI18n[key] = { [camelizedName]: i18n[key] };
});
Locale.add(formattedI18n);
}
return component;
});
}

View File

@ -1,58 +1,58 @@
// This file is auto gererated by build/bin/build-entry.js
import { asyncWrapper, componentWrapper } from './demo-common';
import { wrapper } from './demo-common';
export default {
'actionsheet': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/actionsheet/demo'), 'actionsheet')), 'actionsheet')),
'address-edit': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/address-edit/demo'), 'address-edit')), 'address-edit')),
'address-list': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/address-list/demo'), 'address-list')), 'address-list')),
'area': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/area/demo'), 'area')), 'area')),
'badge': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/badge/demo'), 'badge')), 'badge')),
'button': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/button/demo'), 'button')), 'button')),
'card': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/card/demo'), 'card')), 'card')),
'cell': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/cell/demo'), 'cell')), 'cell')),
'cell-swipe': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/cell-swipe/demo'), 'cell-swipe')), 'cell-swipe')),
'checkbox': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/checkbox/demo'), 'checkbox')), 'checkbox')),
'circle': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/circle/demo'), 'circle')), 'circle')),
'col': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/col/demo'), 'col')), 'col')),
'collapse': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/collapse/demo'), 'collapse')), 'collapse')),
'contact-card': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/contact-card/demo'), 'contact-card')), 'contact-card')),
'coupon-list': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/coupon-list/demo'), 'coupon-list')), 'coupon-list')),
'datetime-picker': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/datetime-picker/demo'), 'datetime-picker')), 'datetime-picker')),
'dialog': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/dialog/demo'), 'dialog')), 'dialog')),
'field': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/field/demo'), 'field')), 'field')),
'goods-action': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/goods-action/demo'), 'goods-action')), 'goods-action')),
'icon': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/icon/demo'), 'icon')), 'icon')),
'image-preview': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/image-preview/demo'), 'image-preview')), 'image-preview')),
'lazyload': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/lazyload/demo'), 'lazyload')), 'lazyload')),
'list': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/list/demo'), 'list')), 'list')),
'loading': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/loading/demo'), 'loading')), 'loading')),
'nav-bar': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/nav-bar/demo'), 'nav-bar')), 'nav-bar')),
'notice-bar': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/notice-bar/demo'), 'notice-bar')), 'notice-bar')),
'number-keyboard': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/number-keyboard/demo'), 'number-keyboard')), 'number-keyboard')),
'pagination': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/pagination/demo'), 'pagination')), 'pagination')),
'panel': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/panel/demo'), 'panel')), 'panel')),
'password-input': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/password-input/demo'), 'password-input')), 'password-input')),
'picker': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/picker/demo'), 'picker')), 'picker')),
'popup': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/popup/demo'), 'popup')), 'popup')),
'progress': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/progress/demo'), 'progress')), 'progress')),
'pull-refresh': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/pull-refresh/demo'), 'pull-refresh')), 'pull-refresh')),
'radio': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/radio/demo'), 'radio')), 'radio')),
'rate': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/rate/demo'), 'rate')), 'rate')),
'search': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/search/demo'), 'search')), 'search')),
'sku': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/sku/demo'), 'sku')), 'sku')),
'slider': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/slider/demo'), 'slider')), 'slider')),
'stepper': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/stepper/demo'), 'stepper')), 'stepper')),
'steps': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/steps/demo'), 'steps')), 'steps')),
'submit-bar': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/submit-bar/demo'), 'submit-bar')), 'submit-bar')),
'swipe': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/swipe/demo'), 'swipe')), 'swipe')),
'switch': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/switch/demo'), 'switch')), 'switch')),
'switch-cell': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/switch-cell/demo'), 'switch-cell')), 'switch-cell')),
'tab': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/tab/demo'), 'tab')), 'tab')),
'tabbar': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/tabbar/demo'), 'tabbar')), 'tabbar')),
'tag': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/tag/demo'), 'tag')), 'tag')),
'toast': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/toast/demo'), 'toast')), 'toast')),
'tree-select': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/tree-select/demo'), 'tree-select')), 'tree-select')),
'uploader': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/uploader/demo'), 'uploader')), 'uploader')),
'vant-css': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/vant-css/demo'), 'vant-css')), 'vant-css')),
'waterfall': asyncWrapper(r => require.ensure([], () => r(componentWrapper(require('../../packages/waterfall/demo'), 'waterfall')), 'waterfall'))
'actionsheet': () => wrapper(import('../../packages/actionsheet/demo'), 'actionsheet'),
'address-edit': () => wrapper(import('../../packages/address-edit/demo'), 'address-edit'),
'address-list': () => wrapper(import('../../packages/address-list/demo'), 'address-list'),
'area': () => wrapper(import('../../packages/area/demo'), 'area'),
'badge': () => wrapper(import('../../packages/badge/demo'), 'badge'),
'button': () => wrapper(import('../../packages/button/demo'), 'button'),
'card': () => wrapper(import('../../packages/card/demo'), 'card'),
'cell': () => wrapper(import('../../packages/cell/demo'), 'cell'),
'cell-swipe': () => wrapper(import('../../packages/cell-swipe/demo'), 'cell-swipe'),
'checkbox': () => wrapper(import('../../packages/checkbox/demo'), 'checkbox'),
'circle': () => wrapper(import('../../packages/circle/demo'), 'circle'),
'col': () => wrapper(import('../../packages/col/demo'), 'col'),
'collapse': () => wrapper(import('../../packages/collapse/demo'), 'collapse'),
'contact-card': () => wrapper(import('../../packages/contact-card/demo'), 'contact-card'),
'coupon-list': () => wrapper(import('../../packages/coupon-list/demo'), 'coupon-list'),
'datetime-picker': () => wrapper(import('../../packages/datetime-picker/demo'), 'datetime-picker'),
'dialog': () => wrapper(import('../../packages/dialog/demo'), 'dialog'),
'field': () => wrapper(import('../../packages/field/demo'), 'field'),
'goods-action': () => wrapper(import('../../packages/goods-action/demo'), 'goods-action'),
'icon': () => wrapper(import('../../packages/icon/demo'), 'icon'),
'image-preview': () => wrapper(import('../../packages/image-preview/demo'), 'image-preview'),
'lazyload': () => wrapper(import('../../packages/lazyload/demo'), 'lazyload'),
'list': () => wrapper(import('../../packages/list/demo'), 'list'),
'loading': () => wrapper(import('../../packages/loading/demo'), 'loading'),
'nav-bar': () => wrapper(import('../../packages/nav-bar/demo'), 'nav-bar'),
'notice-bar': () => wrapper(import('../../packages/notice-bar/demo'), 'notice-bar'),
'number-keyboard': () => wrapper(import('../../packages/number-keyboard/demo'), 'number-keyboard'),
'pagination': () => wrapper(import('../../packages/pagination/demo'), 'pagination'),
'panel': () => wrapper(import('../../packages/panel/demo'), 'panel'),
'password-input': () => wrapper(import('../../packages/password-input/demo'), 'password-input'),
'picker': () => wrapper(import('../../packages/picker/demo'), 'picker'),
'popup': () => wrapper(import('../../packages/popup/demo'), 'popup'),
'progress': () => wrapper(import('../../packages/progress/demo'), 'progress'),
'pull-refresh': () => wrapper(import('../../packages/pull-refresh/demo'), 'pull-refresh'),
'radio': () => wrapper(import('../../packages/radio/demo'), 'radio'),
'rate': () => wrapper(import('../../packages/rate/demo'), 'rate'),
'search': () => wrapper(import('../../packages/search/demo'), 'search'),
'sku': () => wrapper(import('../../packages/sku/demo'), 'sku'),
'slider': () => wrapper(import('../../packages/slider/demo'), 'slider'),
'stepper': () => wrapper(import('../../packages/stepper/demo'), 'stepper'),
'steps': () => wrapper(import('../../packages/steps/demo'), 'steps'),
'submit-bar': () => wrapper(import('../../packages/submit-bar/demo'), 'submit-bar'),
'swipe': () => wrapper(import('../../packages/swipe/demo'), 'swipe'),
'switch': () => wrapper(import('../../packages/switch/demo'), 'switch'),
'switch-cell': () => wrapper(import('../../packages/switch-cell/demo'), 'switch-cell'),
'tab': () => wrapper(import('../../packages/tab/demo'), 'tab'),
'tabbar': () => wrapper(import('../../packages/tabbar/demo'), 'tabbar'),
'tag': () => wrapper(import('../../packages/tag/demo'), 'tag'),
'toast': () => wrapper(import('../../packages/toast/demo'), 'toast'),
'tree-select': () => wrapper(import('../../packages/tree-select/demo'), 'tree-select'),
'uploader': () => wrapper(import('../../packages/uploader/demo'), 'uploader'),
'vant-css': () => wrapper(import('../../packages/vant-css/demo'), 'vant-css'),
'waterfall': () => wrapper(import('../../packages/waterfall/demo'), 'waterfall')
};

View File

@ -1,133 +1,120 @@
// This file is auto gererated by build/bin/build-entry.js
import progress from 'nprogress';
function wrapper(component) {
return function(r) {
progress.start();
component(r).then(() => {
progress.done();
}).catch(() => {
progress.done();
});
};
}
export default {
'changelog.en-US': wrapper(r => require.ensure([], () => r(require('../markdown/changelog.en-US.md')), 'changelog.en-US')),
'changelog.generated': wrapper(r => require.ensure([], () => r(require('../markdown/changelog.generated.md')), 'changelog.generated')),
'changelog.zh-CN': wrapper(r => require.ensure([], () => r(require('../markdown/changelog.zh-CN.md')), 'changelog.zh-CN')),
'intro.en-US': wrapper(r => require.ensure([], () => r(require('../markdown/intro.en-US.md')), 'intro.en-US')),
'intro.zh-CN': wrapper(r => require.ensure([], () => r(require('../markdown/intro.zh-CN.md')), 'intro.zh-CN')),
'quickstart.en-US': wrapper(r => require.ensure([], () => r(require('../markdown/quickstart.en-US.md')), 'quickstart.en-US')),
'quickstart.zh-CN': wrapper(r => require.ensure([], () => r(require('../markdown/quickstart.zh-CN.md')), 'quickstart.zh-CN')),
'theme.en-US': wrapper(r => require.ensure([], () => r(require('../markdown/theme.en-US.md')), 'theme.en-US')),
'theme.zh-CN': wrapper(r => require.ensure([], () => r(require('../markdown/theme.zh-CN.md')), 'theme.zh-CN')),
'actionsheet.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/actionsheet/en-US.md')), 'actionsheet.en-US')),
'actionsheet.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/actionsheet/zh-CN.md')), 'actionsheet.zh-CN')),
'address-edit.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/address-edit/en-US.md')), 'address-edit.en-US')),
'address-edit.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/address-edit/zh-CN.md')), 'address-edit.zh-CN')),
'address-list.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/address-list/en-US.md')), 'address-list.en-US')),
'address-list.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/address-list/zh-CN.md')), 'address-list.zh-CN')),
'area.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/area/en-US.md')), 'area.en-US')),
'area.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/area/zh-CN.md')), 'area.zh-CN')),
'badge.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/badge/en-US.md')), 'badge.en-US')),
'badge.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/badge/zh-CN.md')), 'badge.zh-CN')),
'button.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/button/en-US.md')), 'button.en-US')),
'button.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/button/zh-CN.md')), 'button.zh-CN')),
'card.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/card/en-US.md')), 'card.en-US')),
'card.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/card/zh-CN.md')), 'card.zh-CN')),
'cell.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/cell/en-US.md')), 'cell.en-US')),
'cell.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/cell/zh-CN.md')), 'cell.zh-CN')),
'cell-swipe.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/cell-swipe/en-US.md')), 'cell-swipe.en-US')),
'cell-swipe.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/cell-swipe/zh-CN.md')), 'cell-swipe.zh-CN')),
'checkbox.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/checkbox/en-US.md')), 'checkbox.en-US')),
'checkbox.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/checkbox/zh-CN.md')), 'checkbox.zh-CN')),
'circle.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/circle/en-US.md')), 'circle.en-US')),
'circle.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/circle/zh-CN.md')), 'circle.zh-CN')),
'col.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/col/en-US.md')), 'col.en-US')),
'col.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/col/zh-CN.md')), 'col.zh-CN')),
'collapse.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/collapse/en-US.md')), 'collapse.en-US')),
'collapse.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/collapse/zh-CN.md')), 'collapse.zh-CN')),
'contact-card.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/contact-card/en-US.md')), 'contact-card.en-US')),
'contact-card.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/contact-card/zh-CN.md')), 'contact-card.zh-CN')),
'coupon-list.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/coupon-list/en-US.md')), 'coupon-list.en-US')),
'coupon-list.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/coupon-list/zh-CN.md')), 'coupon-list.zh-CN')),
'datetime-picker.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/datetime-picker/en-US.md')), 'datetime-picker.en-US')),
'datetime-picker.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/datetime-picker/zh-CN.md')), 'datetime-picker.zh-CN')),
'dialog.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/dialog/en-US.md')), 'dialog.en-US')),
'dialog.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/dialog/zh-CN.md')), 'dialog.zh-CN')),
'field.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/field/en-US.md')), 'field.en-US')),
'field.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/field/zh-CN.md')), 'field.zh-CN')),
'goods-action.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/goods-action/en-US.md')), 'goods-action.en-US')),
'goods-action.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/goods-action/zh-CN.md')), 'goods-action.zh-CN')),
'icon.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/icon/en-US.md')), 'icon.en-US')),
'icon.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/icon/zh-CN.md')), 'icon.zh-CN')),
'image-preview.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/image-preview/en-US.md')), 'image-preview.en-US')),
'image-preview.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/image-preview/zh-CN.md')), 'image-preview.zh-CN')),
'lazyload.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/lazyload/en-US.md')), 'lazyload.en-US')),
'lazyload.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/lazyload/zh-CN.md')), 'lazyload.zh-CN')),
'list.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/list/en-US.md')), 'list.en-US')),
'list.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/list/zh-CN.md')), 'list.zh-CN')),
'loading.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/loading/en-US.md')), 'loading.en-US')),
'loading.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/loading/zh-CN.md')), 'loading.zh-CN')),
'locale.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/locale/en-US.md')), 'locale.en-US')),
'locale.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/locale/zh-CN.md')), 'locale.zh-CN')),
'nav-bar.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/nav-bar/en-US.md')), 'nav-bar.en-US')),
'nav-bar.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/nav-bar/zh-CN.md')), 'nav-bar.zh-CN')),
'notice-bar.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/notice-bar/en-US.md')), 'notice-bar.en-US')),
'notice-bar.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/notice-bar/zh-CN.md')), 'notice-bar.zh-CN')),
'number-keyboard.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/number-keyboard/en-US.md')), 'number-keyboard.en-US')),
'number-keyboard.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/number-keyboard/zh-CN.md')), 'number-keyboard.zh-CN')),
'pagination.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/pagination/en-US.md')), 'pagination.en-US')),
'pagination.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/pagination/zh-CN.md')), 'pagination.zh-CN')),
'panel.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/panel/en-US.md')), 'panel.en-US')),
'panel.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/panel/zh-CN.md')), 'panel.zh-CN')),
'password-input.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/password-input/en-US.md')), 'password-input.en-US')),
'password-input.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/password-input/zh-CN.md')), 'password-input.zh-CN')),
'picker.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/picker/en-US.md')), 'picker.en-US')),
'picker.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/picker/zh-CN.md')), 'picker.zh-CN')),
'popup.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/popup/en-US.md')), 'popup.en-US')),
'popup.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/popup/zh-CN.md')), 'popup.zh-CN')),
'progress.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/progress/en-US.md')), 'progress.en-US')),
'progress.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/progress/zh-CN.md')), 'progress.zh-CN')),
'pull-refresh.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/pull-refresh/en-US.md')), 'pull-refresh.en-US')),
'pull-refresh.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/pull-refresh/zh-CN.md')), 'pull-refresh.zh-CN')),
'radio.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/radio/en-US.md')), 'radio.en-US')),
'radio.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/radio/zh-CN.md')), 'radio.zh-CN')),
'rate.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/rate/en-US.md')), 'rate.en-US')),
'rate.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/rate/zh-CN.md')), 'rate.zh-CN')),
'search.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/search/en-US.md')), 'search.en-US')),
'search.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/search/zh-CN.md')), 'search.zh-CN')),
'sku.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/sku/en-US.md')), 'sku.en-US')),
'sku.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/sku/zh-CN.md')), 'sku.zh-CN')),
'slider.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/slider/en-US.md')), 'slider.en-US')),
'slider.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/slider/zh-CN.md')), 'slider.zh-CN')),
'stepper.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/stepper/en-US.md')), 'stepper.en-US')),
'stepper.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/stepper/zh-CN.md')), 'stepper.zh-CN')),
'steps.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/steps/en-US.md')), 'steps.en-US')),
'steps.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/steps/zh-CN.md')), 'steps.zh-CN')),
'submit-bar.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/submit-bar/en-US.md')), 'submit-bar.en-US')),
'submit-bar.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/submit-bar/zh-CN.md')), 'submit-bar.zh-CN')),
'swipe.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/swipe/en-US.md')), 'swipe.en-US')),
'swipe.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/swipe/zh-CN.md')), 'swipe.zh-CN')),
'switch.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/switch/en-US.md')), 'switch.en-US')),
'switch.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/switch/zh-CN.md')), 'switch.zh-CN')),
'switch-cell.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/switch-cell/en-US.md')), 'switch-cell.en-US')),
'switch-cell.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/switch-cell/zh-CN.md')), 'switch-cell.zh-CN')),
'tab.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/tab/en-US.md')), 'tab.en-US')),
'tab.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/tab/zh-CN.md')), 'tab.zh-CN')),
'tabbar.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/tabbar/en-US.md')), 'tabbar.en-US')),
'tabbar.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/tabbar/zh-CN.md')), 'tabbar.zh-CN')),
'tag.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/tag/en-US.md')), 'tag.en-US')),
'tag.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/tag/zh-CN.md')), 'tag.zh-CN')),
'toast.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/toast/en-US.md')), 'toast.en-US')),
'toast.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/toast/zh-CN.md')), 'toast.zh-CN')),
'tree-select.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/tree-select/en-US.md')), 'tree-select.en-US')),
'tree-select.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/tree-select/zh-CN.md')), 'tree-select.zh-CN')),
'uploader.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/uploader/en-US.md')), 'uploader.en-US')),
'uploader.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/uploader/zh-CN.md')), 'uploader.zh-CN')),
'vant-css.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/vant-css/en-US.md')), 'vant-css.en-US')),
'vant-css.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/vant-css/zh-CN.md')), 'vant-css.zh-CN')),
'waterfall.en-US': wrapper(r => require.ensure([], () => r(require('../../packages/waterfall/en-US.md')), 'waterfall.en-US')),
'waterfall.zh-CN': wrapper(r => require.ensure([], () => r(require('../../packages/waterfall/zh-CN.md')), 'waterfall.zh-CN'))
'changelog.en-US': () => import('../markdown/changelog.en-US.md'),
'changelog.generated': () => import('../markdown/changelog.generated.md'),
'changelog.zh-CN': () => import('../markdown/changelog.zh-CN.md'),
'intro.en-US': () => import('../markdown/intro.en-US.md'),
'intro.zh-CN': () => import('../markdown/intro.zh-CN.md'),
'quickstart.en-US': () => import('../markdown/quickstart.en-US.md'),
'quickstart.zh-CN': () => import('../markdown/quickstart.zh-CN.md'),
'theme.en-US': () => import('../markdown/theme.en-US.md'),
'theme.zh-CN': () => import('../markdown/theme.zh-CN.md'),
'actionsheet.en-US': () => import('../../packages/actionsheet/en-US.md'),
'actionsheet.zh-CN': () => import('../../packages/actionsheet/zh-CN.md'),
'address-edit.en-US': () => import('../../packages/address-edit/en-US.md'),
'address-edit.zh-CN': () => import('../../packages/address-edit/zh-CN.md'),
'address-list.en-US': () => import('../../packages/address-list/en-US.md'),
'address-list.zh-CN': () => import('../../packages/address-list/zh-CN.md'),
'area.en-US': () => import('../../packages/area/en-US.md'),
'area.zh-CN': () => import('../../packages/area/zh-CN.md'),
'badge.en-US': () => import('../../packages/badge/en-US.md'),
'badge.zh-CN': () => import('../../packages/badge/zh-CN.md'),
'button.en-US': () => import('../../packages/button/en-US.md'),
'button.zh-CN': () => import('../../packages/button/zh-CN.md'),
'card.en-US': () => import('../../packages/card/en-US.md'),
'card.zh-CN': () => import('../../packages/card/zh-CN.md'),
'cell.en-US': () => import('../../packages/cell/en-US.md'),
'cell.zh-CN': () => import('../../packages/cell/zh-CN.md'),
'cell-swipe.en-US': () => import('../../packages/cell-swipe/en-US.md'),
'cell-swipe.zh-CN': () => import('../../packages/cell-swipe/zh-CN.md'),
'checkbox.en-US': () => import('../../packages/checkbox/en-US.md'),
'checkbox.zh-CN': () => import('../../packages/checkbox/zh-CN.md'),
'circle.en-US': () => import('../../packages/circle/en-US.md'),
'circle.zh-CN': () => import('../../packages/circle/zh-CN.md'),
'col.en-US': () => import('../../packages/col/en-US.md'),
'col.zh-CN': () => import('../../packages/col/zh-CN.md'),
'collapse.en-US': () => import('../../packages/collapse/en-US.md'),
'collapse.zh-CN': () => import('../../packages/collapse/zh-CN.md'),
'contact-card.en-US': () => import('../../packages/contact-card/en-US.md'),
'contact-card.zh-CN': () => import('../../packages/contact-card/zh-CN.md'),
'coupon-list.en-US': () => import('../../packages/coupon-list/en-US.md'),
'coupon-list.zh-CN': () => import('../../packages/coupon-list/zh-CN.md'),
'datetime-picker.en-US': () => import('../../packages/datetime-picker/en-US.md'),
'datetime-picker.zh-CN': () => import('../../packages/datetime-picker/zh-CN.md'),
'dialog.en-US': () => import('../../packages/dialog/en-US.md'),
'dialog.zh-CN': () => import('../../packages/dialog/zh-CN.md'),
'field.en-US': () => import('../../packages/field/en-US.md'),
'field.zh-CN': () => import('../../packages/field/zh-CN.md'),
'goods-action.en-US': () => import('../../packages/goods-action/en-US.md'),
'goods-action.zh-CN': () => import('../../packages/goods-action/zh-CN.md'),
'icon.en-US': () => import('../../packages/icon/en-US.md'),
'icon.zh-CN': () => import('../../packages/icon/zh-CN.md'),
'image-preview.en-US': () => import('../../packages/image-preview/en-US.md'),
'image-preview.zh-CN': () => import('../../packages/image-preview/zh-CN.md'),
'lazyload.en-US': () => import('../../packages/lazyload/en-US.md'),
'lazyload.zh-CN': () => import('../../packages/lazyload/zh-CN.md'),
'list.en-US': () => import('../../packages/list/en-US.md'),
'list.zh-CN': () => import('../../packages/list/zh-CN.md'),
'loading.en-US': () => import('../../packages/loading/en-US.md'),
'loading.zh-CN': () => import('../../packages/loading/zh-CN.md'),
'locale.en-US': () => import('../../packages/locale/en-US.md'),
'locale.zh-CN': () => import('../../packages/locale/zh-CN.md'),
'nav-bar.en-US': () => import('../../packages/nav-bar/en-US.md'),
'nav-bar.zh-CN': () => import('../../packages/nav-bar/zh-CN.md'),
'notice-bar.en-US': () => import('../../packages/notice-bar/en-US.md'),
'notice-bar.zh-CN': () => import('../../packages/notice-bar/zh-CN.md'),
'number-keyboard.en-US': () => import('../../packages/number-keyboard/en-US.md'),
'number-keyboard.zh-CN': () => import('../../packages/number-keyboard/zh-CN.md'),
'pagination.en-US': () => import('../../packages/pagination/en-US.md'),
'pagination.zh-CN': () => import('../../packages/pagination/zh-CN.md'),
'panel.en-US': () => import('../../packages/panel/en-US.md'),
'panel.zh-CN': () => import('../../packages/panel/zh-CN.md'),
'password-input.en-US': () => import('../../packages/password-input/en-US.md'),
'password-input.zh-CN': () => import('../../packages/password-input/zh-CN.md'),
'picker.en-US': () => import('../../packages/picker/en-US.md'),
'picker.zh-CN': () => import('../../packages/picker/zh-CN.md'),
'popup.en-US': () => import('../../packages/popup/en-US.md'),
'popup.zh-CN': () => import('../../packages/popup/zh-CN.md'),
'progress.en-US': () => import('../../packages/progress/en-US.md'),
'progress.zh-CN': () => import('../../packages/progress/zh-CN.md'),
'pull-refresh.en-US': () => import('../../packages/pull-refresh/en-US.md'),
'pull-refresh.zh-CN': () => import('../../packages/pull-refresh/zh-CN.md'),
'radio.en-US': () => import('../../packages/radio/en-US.md'),
'radio.zh-CN': () => import('../../packages/radio/zh-CN.md'),
'rate.en-US': () => import('../../packages/rate/en-US.md'),
'rate.zh-CN': () => import('../../packages/rate/zh-CN.md'),
'search.en-US': () => import('../../packages/search/en-US.md'),
'search.zh-CN': () => import('../../packages/search/zh-CN.md'),
'sku.en-US': () => import('../../packages/sku/en-US.md'),
'sku.zh-CN': () => import('../../packages/sku/zh-CN.md'),
'slider.en-US': () => import('../../packages/slider/en-US.md'),
'slider.zh-CN': () => import('../../packages/slider/zh-CN.md'),
'stepper.en-US': () => import('../../packages/stepper/en-US.md'),
'stepper.zh-CN': () => import('../../packages/stepper/zh-CN.md'),
'steps.en-US': () => import('../../packages/steps/en-US.md'),
'steps.zh-CN': () => import('../../packages/steps/zh-CN.md'),
'submit-bar.en-US': () => import('../../packages/submit-bar/en-US.md'),
'submit-bar.zh-CN': () => import('../../packages/submit-bar/zh-CN.md'),
'swipe.en-US': () => import('../../packages/swipe/en-US.md'),
'swipe.zh-CN': () => import('../../packages/swipe/zh-CN.md'),
'switch.en-US': () => import('../../packages/switch/en-US.md'),
'switch.zh-CN': () => import('../../packages/switch/zh-CN.md'),
'switch-cell.en-US': () => import('../../packages/switch-cell/en-US.md'),
'switch-cell.zh-CN': () => import('../../packages/switch-cell/zh-CN.md'),
'tab.en-US': () => import('../../packages/tab/en-US.md'),
'tab.zh-CN': () => import('../../packages/tab/zh-CN.md'),
'tabbar.en-US': () => import('../../packages/tabbar/en-US.md'),
'tabbar.zh-CN': () => import('../../packages/tabbar/zh-CN.md'),
'tag.en-US': () => import('../../packages/tag/en-US.md'),
'tag.zh-CN': () => import('../../packages/tag/zh-CN.md'),
'toast.en-US': () => import('../../packages/toast/en-US.md'),
'toast.zh-CN': () => import('../../packages/toast/zh-CN.md'),
'tree-select.en-US': () => import('../../packages/tree-select/en-US.md'),
'tree-select.zh-CN': () => import('../../packages/tree-select/zh-CN.md'),
'uploader.en-US': () => import('../../packages/uploader/en-US.md'),
'uploader.zh-CN': () => import('../../packages/uploader/zh-CN.md'),
'vant-css.en-US': () => import('../../packages/vant-css/en-US.md'),
'vant-css.zh-CN': () => import('../../packages/vant-css/zh-CN.md'),
'waterfall.en-US': () => import('../../packages/waterfall/en-US.md'),
'waterfall.zh-CN': () => import('../../packages/waterfall/zh-CN.md')
};

View File

@ -3,6 +3,7 @@ import VueRouter from 'vue-router';
import App from './DocsApp';
import routes from './router';
import VantDoc from 'vant-doc';
import progress from 'nprogress';
import { isMobile } from './utils';
import './components/nprogress.css';
@ -18,11 +19,13 @@ router.beforeEach((route, redirect, next) => {
if (isMobile) {
location.replace(location.pathname === '/' ? 'examples.html' : '/zanui/vant/examples' + location.hash);
}
progress.start();
document.title = route.meta.title || document.title;
next();
});
router.afterEach(() => {
progress.done();
window.scrollTo(0, 0);
Vue.nextTick(() => window.syncPath());
});

View File

@ -2,6 +2,7 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './WapApp';
import routes from './router';
import progress from 'nprogress';
import '../../packages/vant-css/src/index.css';
import '../../packages/vant-css/src/icon-local.css';
import 'vant-doc/src/helper/touch-simulator';
@ -13,7 +14,13 @@ const router = new VueRouter({
routes: routes(true)
});
router.beforeEach((route, redirect, next) => {
progress.start();
next();
});
router.afterEach(() => {
progress.done();
if (router.currentRoute.name) {
window.scrollTo(0, 0);
}

View File

@ -64,9 +64,9 @@
"babel-core": "^6.26.3",
"babel-jest": "^23.0.0",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"codecov": "^3.0.0",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",

View File

@ -851,6 +851,10 @@ babel-plugin-syntax-decorators@^6.13.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b"
babel-plugin-syntax-do-expressions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-do-expressions/-/babel-plugin-syntax-do-expressions-6.13.0.tgz#5747756139aa26d390d09410b03744ba07e4796d"
babel-plugin-syntax-dynamic-import@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da"
@ -867,6 +871,10 @@ babel-plugin-syntax-flow@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz#4c3ab20a2af26aa20cd25995c398c4eb70310c8d"
babel-plugin-syntax-function-bind@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-function-bind/-/babel-plugin-syntax-function-bind-6.13.0.tgz#48c495f177bdf31a981e732f55adc0bdd2601f46"
babel-plugin-syntax-object-rest-spread@^6.13.0, babel-plugin-syntax-object-rest-spread@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
@ -918,6 +926,13 @@ babel-plugin-transform-decorators@^6.24.1:
babel-template "^6.24.1"
babel-types "^6.24.1"
babel-plugin-transform-do-expressions@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-do-expressions/-/babel-plugin-transform-do-expressions-6.22.0.tgz#28ccaf92812d949c2cd1281f690c8fdc468ae9bb"
dependencies:
babel-plugin-syntax-do-expressions "^6.8.0"
babel-runtime "^6.22.0"
babel-plugin-transform-es2015-arrow-functions@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221"
@ -1117,7 +1132,14 @@ babel-plugin-transform-flow-strip-types@^6.8.0:
babel-plugin-syntax-flow "^6.18.0"
babel-runtime "^6.22.0"
babel-plugin-transform-object-rest-spread@^6.22.0, babel-plugin-transform-object-rest-spread@^6.26.0:
babel-plugin-transform-function-bind@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-function-bind/-/babel-plugin-transform-function-bind-6.22.0.tgz#c6fb8e96ac296a310b8cf8ea401462407ddf6a97"
dependencies:
babel-plugin-syntax-function-bind "^6.8.0"
babel-runtime "^6.22.0"
babel-plugin-transform-object-rest-spread@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06"
dependencies:
@ -1222,7 +1244,15 @@ babel-preset-jest@^23.0.0:
babel-plugin-jest-hoist "^23.0.0"
babel-plugin-syntax-object-rest-spread "^6.13.0"
babel-preset-stage-1@^6.5.0:
babel-preset-stage-0@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-preset-stage-0/-/babel-preset-stage-0-6.24.1.tgz#5642d15042f91384d7e5af8bc88b1db95b039e6a"
dependencies:
babel-plugin-transform-do-expressions "^6.22.0"
babel-plugin-transform-function-bind "^6.22.0"
babel-preset-stage-1 "^6.24.1"
babel-preset-stage-1@^6.24.1, babel-preset-stage-1@^6.5.0:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-preset-stage-1/-/babel-preset-stage-1-6.24.1.tgz#7692cd7dcd6849907e6ae4a0a85589cfb9e2bfb0"
dependencies: