chore(cli): update eslint config and prettier codes

This commit is contained in:
陈嘉涵 2020-01-19 11:42:22 +08:00
parent 633e9cf59d
commit 1691451813
52 changed files with 383 additions and 363 deletions

View File

@ -54,7 +54,7 @@
"@babel/preset-env": "^7.7.7", "@babel/preset-env": "^7.7.7",
"@babel/preset-typescript": "^7.7.7", "@babel/preset-typescript": "^7.7.7",
"@nuxt/friendly-errors-webpack-plugin": "^2.5.0", "@nuxt/friendly-errors-webpack-plugin": "^2.5.0",
"@vant/eslint-config": "^1.5.1", "@vant/eslint-config": "^2.0.0",
"@vant/markdown-loader": "^2.3.0", "@vant/markdown-loader": "^2.3.0",
"@vant/markdown-vetur": "^1.1.0", "@vant/markdown-vetur": "^1.1.0",
"@vant/stylelint-config": "^1.1.0", "@vant/stylelint-config": "^1.1.0",

View File

@ -4,7 +4,7 @@
import { iframeReady, isMobile } from '.'; import { iframeReady, isMobile } from '.';
window.syncPath = function () { window.syncPath = function() {
const router = window.vueRouter; const router = window.vueRouter;
const isInIframe = window !== window.top; const isInIframe = window !== window.top;
const currentDir = router.history.current.path; const currentDir = router.history.current.path;
@ -21,7 +21,7 @@ window.syncPath = function () {
} }
}; };
window.replacePath = function (path = '') { window.replacePath = function(path = '') {
// should preserve hash for anchor // should preserve hash for anchor
if (window.vueRouter.currentRoute.path !== path) { if (window.vueRouter.currentRoute.path !== path) {
window.vueRouter.replace(path).catch(() => {}); window.vueRouter.replace(path).catch(() => {});

View File

@ -27,7 +27,4 @@ export function decamelize(str, sep = '-') {
.toLowerCase(); .toLowerCase();
} }
export { export { isMobile, iframeReady };
isMobile,
iframeReady
};

View File

@ -4,7 +4,7 @@
@van-doc-fuchsia: #a7419e; @van-doc-fuchsia: #a7419e;
@van-doc-green: #4fc08d; @van-doc-green: #4fc08d;
@van-doc-text-color: #34495e; @van-doc-text-color: #34495e;
@van-doc-text-light-blue: rgba(69, 90, 100, .6); @van-doc-text-light-blue: rgba(69, 90, 100, 0.6);
@van-doc-background-color: #f7f8fa; @van-doc-background-color: #f7f8fa;
@van-doc-grey: #999; @van-doc-grey: #999;
@van-doc-dark-grey: #666; @van-doc-dark-grey: #666;

View File

@ -19,7 +19,7 @@ import { setLang } from '../common/locales';
export default { export default {
components: { components: {
VanDoc VanDoc,
}, },
data() { data() {
@ -27,7 +27,7 @@ export default {
return { return {
packageVersion, packageVersion,
simulator: `${path}mobile.html${location.hash}` simulator: `${path}mobile.html${location.hash}`,
}; };
}, },
@ -41,7 +41,7 @@ export default {
const { locales = {} } = config.site; const { locales = {} } = config.site;
return Object.keys(locales).map(key => ({ return Object.keys(locales).map(key => ({
lang: key, lang: key,
label: locales[key].langLabel || '' label: locales[key].langLabel || '',
})); }));
}, },
@ -61,14 +61,14 @@ export default {
} }
return null; return null;
} },
}, },
watch: { watch: {
lang(val) { lang(val) {
setLang(val); setLang(val);
this.setTitle(); this.setTitle();
} },
}, },
created() { created() {
@ -84,8 +84,8 @@ export default {
} }
document.title = title; document.title = title;
} },
} },
}; };
</script> </script>

View File

@ -12,8 +12,8 @@ export default {
name: 'van-doc-container', name: 'van-doc-container',
props: { props: {
hasSimulator: Boolean hasSimulator: Boolean,
} },
}; };
</script> </script>

View File

@ -15,8 +15,8 @@ export default {
return path.split('/').slice(-1)[0]; return path.split('/').slice(-1)[0];
} }
return this.$route.name; return this.$route.name;
} },
} },
}; };
</script> </script>

View File

@ -3,21 +3,36 @@
<div class="van-doc-row"> <div class="van-doc-row">
<div class="van-doc-header__top"> <div class="van-doc-header__top">
<a class="van-doc-header__logo"> <a class="van-doc-header__logo">
<img :src="config.logo"> <img :src="config.logo" />
<span>{{ config.title }}</span> <span>{{ config.title }}</span>
</a> </a>
<search-input v-if="searchConfig" :lang="lang" :search-config="searchConfig" /> <search-input
v-if="searchConfig"
:lang="lang"
:search-config="searchConfig"
/>
<ul class="van-doc-header__top-nav"> <ul class="van-doc-header__top-nav">
<li v-for="item in config.links" class="van-doc-header__top-nav-item"> <li v-for="item in config.links" class="van-doc-header__top-nav-item">
<a class="van-doc-header__logo-link" target="_blank" :href="item.url"> <a
<img :src="item.logo"> class="van-doc-header__logo-link"
target="_blank"
:href="item.url"
>
<img :src="item.logo" />
</a> </a>
</li> </li>
<li ref="version" v-if="versions" class="van-doc-header__top-nav-item"> <li
<span class="van-doc-header__cube van-doc-header__version" @click="toggleVersionPop"> ref="version"
v-if="versions"
class="van-doc-header__top-nav-item"
>
<span
class="van-doc-header__cube van-doc-header__version"
@click="toggleVersionPop"
>
{{ versions[0].label }} {{ versions[0].label }}
<transition name="van-doc-dropdown"> <transition name="van-doc-dropdown">
<div v-if="showVersionPop" class="van-doc-header__version-pop"> <div v-if="showVersionPop" class="van-doc-header__version-pop">
@ -49,19 +64,19 @@ export default {
name: 'van-doc-header', name: 'van-doc-header',
components: { components: {
SearchInput SearchInput,
}, },
props: { props: {
lang: String, lang: String,
config: Object, config: Object,
versions: Array, versions: Array,
langConfigs: Array langConfigs: Array,
}, },
data() { data() {
return { return {
showVersionPop: false showVersionPop: false,
}; };
}, },
@ -85,7 +100,7 @@ export default {
searchConfig() { searchConfig() {
return this.config.searchConfig; return this.config.searchConfig;
} },
}, },
methods: { methods: {
@ -93,7 +108,10 @@ export default {
const val = !this.showVersionPop; const val = !this.showVersionPop;
const action = val ? 'add' : 'remove'; const action = val ? 'add' : 'remove';
document.body[`${action}EventListener`]('click', this.checkHideVersionPop); document.body[`${action}EventListener`](
'click',
this.checkHideVersionPop
);
this.showVersionPop = val; this.showVersionPop = val;
}, },
@ -110,8 +128,8 @@ export default {
onSwitchVersion(version) { onSwitchVersion(version) {
location.href = version.link; location.href = version.link;
} },
} },
}; };
</script> </script>

View File

@ -28,18 +28,18 @@ export default {
name: 'van-doc-nav', name: 'van-doc-nav',
components: { components: {
[NavLink.name]: NavLink [NavLink.name]: NavLink,
}, },
props: { props: {
lang: String, lang: String,
navConfig: Array navConfig: Array,
}, },
data() { data() {
return { return {
top: 60, top: 60,
bottom: 0 bottom: 0,
}; };
}, },
@ -47,13 +47,13 @@ export default {
style() { style() {
return { return {
top: this.top + 'px', top: this.top + 'px',
bottom: this.bottom + 'px' bottom: this.bottom + 'px',
}; };
}, },
base() { base() {
return this.lang ? `/${this.lang}/` : '/'; return this.lang ? `/${this.lang}/` : '/';
} },
}, },
created() { created() {
@ -65,8 +65,8 @@ export default {
onScroll() { onScroll() {
const { pageYOffset: offset } = window; const { pageYOffset: offset } = window;
this.top = Math.max(0, 60 - offset); this.top = Math.max(0, 60 - offset);
} },
} },
}; };
</script> </script>

View File

@ -1,7 +1,12 @@
<template> <template>
<router-link v-if="item.path" :class="{ active }" :to="path" v-html="itemName" /> <router-link
v-if="item.path"
:class="{ active }"
:to="path"
v-html="itemName"
/>
<a v-else-if="item.link" :href="item.link" v-html="itemName" /> <a v-else-if="item.link" :href="item.link" v-html="itemName" />
<a v-else v-html="itemName " /> <a v-else v-html="itemName" />
</template> </template>
<script> <script>
@ -10,7 +15,7 @@ export default {
props: { props: {
base: String, base: String,
item: Object item: Object,
}, },
computed: { computed: {
@ -33,13 +38,13 @@ export default {
} }
return false; return false;
} },
}, },
watch: { watch: {
active() { active() {
this.scrollIntoView(); this.scrollIntoView();
} },
}, },
mounted() { mounted() {
@ -51,7 +56,7 @@ export default {
if (this.active && this.$el && this.$el.scrollIntoViewIfNeeded) { if (this.active && this.$el && this.$el.scrollIntoViewIfNeeded) {
this.$el.scrollIntoViewIfNeeded(); this.$el.scrollIntoViewIfNeeded();
} }
} },
} },
}; };
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<input class="van-doc-search" :placeholder="placeholder"> <input class="van-doc-search" :placeholder="placeholder" />
</template> </template>
<script> <script>
@ -8,13 +8,13 @@ export default {
props: { props: {
lang: String, lang: String,
searchConfig: Object searchConfig: Object,
}, },
computed: { computed: {
placeholder() { placeholder() {
return this.searchConfig.placeholder || 'Search...'; return this.searchConfig.placeholder || 'Search...';
} },
}, },
watch: { watch: {
@ -22,7 +22,7 @@ export default {
if (this.docsearchInstance) { if (this.docsearchInstance) {
this.docsearchInstance.algoliaOptions.facetFilters = [`lang:${lang}`]; this.docsearchInstance.algoliaOptions.facetFilters = [`lang:${lang}`];
} }
} },
}, },
mounted() { mounted() {
@ -31,11 +31,11 @@ export default {
...this.searchConfig, ...this.searchConfig,
inputSelector: '.van-doc-search', inputSelector: '.van-doc-search',
algoliaOptions: { algoliaOptions: {
facetFilters: [`lang:${this.lang}`] facetFilters: [`lang:${this.lang}`],
} },
}); });
} }
} },
}; };
</script> </script>

View File

@ -9,13 +9,13 @@ export default {
name: 'van-doc-simulator', name: 'van-doc-simulator',
props: { props: {
src: String src: String,
}, },
data() { data() {
return { return {
scrollTop: window.scrollY, scrollTop: window.scrollY,
windowHeight: window.innerHeight windowHeight: window.innerHeight,
}; };
}, },
@ -27,9 +27,9 @@ export default {
simulatorStyle() { simulatorStyle() {
const height = Math.min(640, this.windowHeight - 90); const height = Math.min(640, this.windowHeight - 90);
return { return {
height: height + 'px' height: height + 'px',
}; };
} },
}, },
mounted() { mounted() {
@ -39,7 +39,7 @@ export default {
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
this.windowHeight = window.innerHeight; this.windowHeight = window.innerHeight;
}); });
} },
}; };
</script> </script>

View File

@ -8,7 +8,7 @@
@switch-version="$emit('switch-version', $event)" @switch-version="$emit('switch-version', $event)"
/> />
<doc-nav :lang="lang" :nav-config="config.nav" /> <doc-nav :lang="lang" :nav-config="config.nav" />
<doc-container :has-simulator="!!simulator "> <doc-container :has-simulator="!!simulator">
<doc-content> <doc-content>
<slot /> <slot />
</doc-content> </doc-content>
@ -32,7 +32,7 @@ export default {
DocHeader, DocHeader,
DocContent, DocContent,
DocContainer, DocContainer,
DocSimulator DocSimulator,
}, },
props: { props: {
@ -42,19 +42,19 @@ export default {
langConfigs: Array, langConfigs: Array,
config: { config: {
type: Object, type: Object,
required: true required: true,
}, },
base: { base: {
type: String, type: String,
default: '' default: '',
} },
}, },
watch: { watch: {
// eslint-disable-next-line // eslint-disable-next-line
'$route.path'() { '$route.path'() {
this.setNav(); this.setNav();
} },
}, },
created() { created() {
@ -98,8 +98,8 @@ export default {
break; break;
} }
}); });
} },
} },
}; };
</script> </script>

View File

@ -1,29 +1,43 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" /> <meta
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" /> name="description"
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> content="<%= htmlWebpackPlugin.options.description %>"
<meta http-Equiv="Cache-Control" Content="no-cache" /> />
<meta http-Equiv="Pragma" Content="no-cache" /> <link
<meta http-Equiv="Expires" Content="0" /> rel="icon"
<link href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" rel="stylesheet" /> type="image/png"
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %> href="<%= htmlWebpackPlugin.options.logo %>"
<script> />
var _hmt = _hmt || []; <meta
(function() { name="viewport"
var hm = document.createElement("script"); content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
hm.src = "https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>"; />
var s = document.getElementsByTagName("script")[0]; <meta http-equiv="Cache-Control" content="no-cache" />
s.parentNode.insertBefore(hm, s); <meta http-equiv="Pragma" content="no-cache" />
})(); <meta http-equiv="Expires" content="0" />
</script> <link
<% } %> href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"
</head> rel="stylesheet"
<body ontouchstart> />
<div id="app"></div> <% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script> <script>
</body> var _hmt = _hmt || [];
(function() {
var hm = document.createElement('script');
hm.src =
'https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<% } %>
</head>
<body ontouchstart>
<div id="app"></div>
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
</body>
</html> </html>

View File

@ -15,5 +15,5 @@ new Vue({
} }
}, },
render: h => h(App), render: h => h(App),
router router,
}); });

View File

@ -20,13 +20,13 @@ function parseName(name) {
return { return {
component: `${decamelize(component)}`, component: `${decamelize(component)}`,
lang: pairs.join('-') lang: pairs.join('-'),
}; };
} }
return { return {
component: `${decamelize(name)}`, component: `${decamelize(name)}`,
lang: '' lang: '',
}; };
} }
@ -48,12 +48,12 @@ function getRoutes() {
if (locales) { if (locales) {
routes.push({ routes.push({
path: '*', path: '*',
redirect: route => `/${getLangFromRoute(route)}/` redirect: route => `/${getLangFromRoute(route)}/`,
}); });
} else { } else {
routes.push({ routes.push({
path: '*', path: '*',
redirect: '/' redirect: '/',
}); });
} }
@ -62,7 +62,7 @@ function getRoutes() {
name: lang, name: lang,
path: `/${lang || ''}`, path: `/${lang || ''}`,
component: Home, component: Home,
meta: { lang } meta: { lang },
}); });
} }
@ -80,8 +80,8 @@ function getRoutes() {
component: documents[name], component: documents[name],
meta: { meta: {
lang, lang,
name: component name: component,
} },
}); });
} else { } else {
routes.push({ routes.push({
@ -89,8 +89,8 @@ function getRoutes() {
path: `/${component}`, path: `/${component}`,
component: documents[name], component: documents[name],
meta: { meta: {
name: component name: component,
} },
}); });
} }
}); });
@ -109,7 +109,7 @@ export const router = new VueRouter({
} }
return { x: 0, y: 0 }; return { x: 0, y: 0 };
} },
}); });
router.afterEach(() => { router.afterEach(() => {

View File

@ -5,7 +5,7 @@ export function scrollToAnchor(selector) {
const el = document.querySelector(selector); const el = document.querySelector(selector);
if (el) { if (el) {
el.scrollIntoView({ el.scrollIntoView({
behavior: 'smooth' behavior: 'smooth',
}); });
clearInterval(timer); clearInterval(timer);
} else { } else {

View File

@ -11,7 +11,7 @@
import DemoNav from './components/DemoNav'; import DemoNav from './components/DemoNav';
export default { export default {
components: { DemoNav } components: { DemoNav },
}; };
</script> </script>

View File

@ -10,8 +10,8 @@ export default {
name: 'demo-block', name: 'demo-block',
props: { props: {
title: String title: String,
} },
}; };
</script> </script>

View File

@ -4,16 +4,14 @@
class="demo-home__title" class="demo-home__title"
:class="{ 'demo-home__title--small': smallTitle }" :class="{ 'demo-home__title--small': smallTitle }"
> >
<img :src="config.logo"> <img :src="config.logo" />
<span>{{ config.title }}</span> <span>{{ config.title }}</span>
</h1> </h1>
<h2 v-if="config.description" class="demo-home__desc">{{ config.description }}</h2> <h2 v-if="config.description" class="demo-home__desc">
{{ config.description }}
</h2>
<template v-for="(group, index) in config.nav"> <template v-for="(group, index) in config.nav">
<demo-home-nav <demo-home-nav :group="group" :lang="lang" :key="index" />
:group="group"
:lang="lang"
:key="index"
/>
</template> </template>
</div> </div>
</template> </template>
@ -24,7 +22,7 @@ import DemoHomeNav from './DemoHomeNav';
export default { export default {
components: { components: {
DemoHomeNav DemoHomeNav,
}, },
computed: { computed: {
@ -45,8 +43,8 @@ export default {
smallTitle() { smallTitle() {
return this.config.title.length >= 8; return this.config.title.length >= 8;
} },
} },
}; };
</script> </script>

View File

@ -20,25 +20,25 @@ import ArrowRight from './ArrowRight';
export default { export default {
components: { components: {
ArrowRight ArrowRight,
}, },
props: { props: {
lang: String, lang: String,
group: Object group: Object,
}, },
data() { data() {
return { return {
active: [] active: [],
}; };
}, },
computed: { computed: {
base() { base() {
return this.lang ? `/${this.lang}` : ''; return this.lang ? `/${this.lang}` : '';
} },
} },
}; };
</script> </script>

View File

@ -13,7 +13,7 @@ export default {
data() { data() {
return { return {
path: path:
'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z' 'M296.114 508.035c-3.22-13.597.473-28.499 11.079-39.105l333.912-333.912c16.271-16.272 42.653-16.272 58.925 0s16.272 42.654 0 58.926L395.504 498.47l304.574 304.574c16.272 16.272 16.272 42.654 0 58.926s-42.654 16.272-58.926 0L307.241 528.058a41.472 41.472 0 0 1-11.127-20.023z',
}; };
}, },
@ -21,14 +21,14 @@ export default {
title() { title() {
const { name } = this.$route.meta || {}; const { name } = this.$route.meta || {};
return name ? name.replace(/-/g, '') : ''; return name ? name.replace(/-/g, '') : '';
} },
}, },
methods: { methods: {
onBack() { onBack() {
history.back(); history.back();
} },
} },
}; };
</script> </script>

View File

@ -18,8 +18,8 @@ export default {
} }
return ''; return '';
} },
} },
}; };
</script> </script>

View File

@ -1,30 +1,41 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8" />
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<meta name="description" content="<%= htmlWebpackPlugin.options.description %>" /> <meta
<link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.logo %>" /> name="description"
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> content="<%= htmlWebpackPlugin.options.description %>"
<meta http-Equiv="Cache-Control" Content="no-cache" /> />
<meta http-Equiv="Pragma" Content="no-cache" /> <link
<meta http-Equiv="Expires" Content="0" /> rel="icon"
<% if (htmlWebpackPlugin.options.baiduAnalytics) { %> type="image/png"
<script> href="<%= htmlWebpackPlugin.options.logo %>"
// avoid to load analytics in iframe />
if (window.top === window) { <meta
var _hmt = _hmt || []; name="viewport"
(function() { content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
var hm = document.createElement("script"); />
hm.src = "https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>"; <meta http-equiv="Cache-Control" content="no-cache" />
var s = document.getElementsByTagName("script")[0]; <meta http-equiv="Pragma" content="no-cache" />
s.parentNode.insertBefore(hm, s); <meta http-equiv="Expires" content="0" />
})(); <% if (htmlWebpackPlugin.options.baiduAnalytics) { %>
} <script>
</script> // avoid to load analytics in iframe
<% } %> if (window.top === window) {
</head> var _hmt = _hmt || [];
<body ontouchstart> (function() {
<div id="app"></div> var hm = document.createElement('script');
</body> hm.src =
'https://hm.baidu.com/hm.js?<%= htmlWebpackPlugin.options.baiduAnalytics.seed %>';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
}
</script>
<% } %>
</head>
<body ontouchstart>
<div id="app"></div>
</body>
</html> </html>

View File

@ -16,6 +16,6 @@ setTimeout(() => {
new Vue({ new Vue({
el: '#app', el: '#app',
render: h => h(App), render: h => h(App),
router router,
}); });
}, 0); }, 0);

View File

@ -29,25 +29,25 @@ function getRoutes() {
if (langs.length) { if (langs.length) {
routes.push({ routes.push({
path: '*', path: '*',
redirect: route => `/${getLangFromRoute(route)}/` redirect: route => `/${getLangFromRoute(route)}/`,
}); });
langs.forEach(lang => { langs.forEach(lang => {
routes.push({ routes.push({
path: `/${lang}`, path: `/${lang}`,
component: DemoHome, component: DemoHome,
meta: { lang } meta: { lang },
}); });
}); });
} else { } else {
routes.push({ routes.push({
path: '*', path: '*',
redirect: () => '/' redirect: () => '/',
}); });
routes.push({ routes.push({
path: '/', path: '/',
component: DemoHome component: DemoHome,
}); });
} }
@ -62,8 +62,8 @@ function getRoutes() {
component: demos[name], component: demos[name],
meta: { meta: {
name, name,
lang lang,
} },
}); });
}); });
} else { } else {
@ -72,8 +72,8 @@ function getRoutes() {
path: `/${component}`, path: `/${component}`,
component: demos[name], component: demos[name],
meta: { meta: {
name name,
} },
}); });
} }
}); });
@ -86,7 +86,7 @@ Vue.use(VueRouter);
export const router = new VueRouter({ export const router = new VueRouter({
mode: 'hash', mode: 'hash',
routes: getRoutes(), routes: getRoutes(),
scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 } scrollBehavior: (to, from, savedPosition) => savedPosition || { x: 0, y: 0 },
}); });
router.afterEach(() => { router.afterEach(() => {

View File

@ -23,7 +23,7 @@ import {
isDemoDir, isDemoDir,
isTestDir, isTestDir,
setNodeEnv, setNodeEnv,
setModuleEnv setModuleEnv,
} from '../common'; } from '../common';
async function compileFile(filePath: string) { async function compileFile(filePath: string) {
@ -62,7 +62,6 @@ async function compileDir(dir: string) {
); );
} }
async function buildEs() { async function buildEs() {
setModuleEnv('esmodule'); setModuleEnv('esmodule');
await copy(SRC_DIR, ES_DIR); await copy(SRC_DIR, ES_DIR);
@ -87,7 +86,7 @@ async function buildPacakgeEntry() {
genPackageEntry({ genPackageEntry({
outputPath: esEntryFile, outputPath: esEntryFile,
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}` pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`,
}); });
setModuleEnv('esmodule'); setModuleEnv('esmodule');
@ -95,7 +94,7 @@ async function buildPacakgeEntry() {
genPacakgeStyle({ genPacakgeStyle({
outputPath: styleEntryFile, outputPath: styleEntryFile,
pathResolver: (path: string) => path.replace(SRC_DIR, '.') pathResolver: (path: string) => path.replace(SRC_DIR, '.'),
}); });
setModuleEnv('commonjs'); setModuleEnv('commonjs');
@ -114,24 +113,24 @@ async function buildPackages() {
const tasks = [ const tasks = [
{ {
text: 'Build ESModule Outputs', text: 'Build ESModule Outputs',
task: buildEs task: buildEs,
}, },
{ {
text: 'Build Commonjs Outputs', text: 'Build Commonjs Outputs',
task: buildLib task: buildLib,
}, },
{ {
text: 'Build Style Entry', text: 'Build Style Entry',
task: buildStyleEntry task: buildStyleEntry,
}, },
{ {
text: 'Build Package Entry', text: 'Build Package Entry',
task: buildPacakgeEntry task: buildPacakgeEntry,
}, },
{ {
text: 'Build Packed Outputs', text: 'Build Packed Outputs',
task: buildPackages task: buildPackages,
} },
]; ];
async function runBuildTasks() { async function runBuildTasks() {

View File

@ -19,7 +19,7 @@ function formatType(type: string) {
fix: 'Bug Fixes', fix: 'Bug Fixes',
feat: 'Feature', feat: 'Feature',
docs: 'Document', docs: 'Document',
types: 'Types' types: 'Types',
}; };
return MAP[type] || type; return MAP[type] || type;
@ -52,7 +52,7 @@ export async function changelog() {
return new Promise(resolve => { return new Promise(resolve => {
conventionalChangelog( conventionalChangelog(
{ {
preset: 'angular' preset: 'angular',
}, },
null, null,
null, null,
@ -61,7 +61,7 @@ export async function changelog() {
mainTemplate, mainTemplate,
headerPartial, headerPartial,
commitPartial, commitPartial,
transform transform,
} }
) )
.pipe(createWriteStream(DIST_FILE)) .pipe(createWriteStream(DIST_FILE))

View File

@ -6,6 +6,6 @@ export async function clean() {
emptyDir(ES_DIR), emptyDir(ES_DIR),
emptyDir(LIB_DIR), emptyDir(LIB_DIR),
emptyDir(DIST_DIR), emptyDir(DIST_DIR),
emptyDir(SITE_DIST_DIR) emptyDir(SITE_DIST_DIR),
]); ]);
} }

View File

@ -7,14 +7,14 @@ export function test(command: any) {
setNodeEnv('test'); setNodeEnv('test');
genPackageEntry({ genPackageEntry({
outputPath: PACKAGE_ENTRY_FILE outputPath: PACKAGE_ENTRY_FILE,
}); });
const config = { const config = {
rootDir: ROOT, rootDir: ROOT,
watch: command.watch, watch: command.watch,
config: JEST_CONFIG_FILE, config: JEST_CONFIG_FILE,
clearCache: command.clearCache clearCache: command.clearCache,
} as any; } as any;
runCLI(config, [ROOT]) runCLI(config, [ROOT])

View File

@ -18,7 +18,7 @@ function runCommand(
return new Promise(resolve => { return new Promise(resolve => {
execa(cmd, options, { execa(cmd, options, {
env: { FORCE_COLOR: true } env: { FORCE_COLOR: true },
}) })
.then(() => { .then(() => {
spinner.succeed(messages.succeed); spinner.succeed(messages.succeed);
@ -39,7 +39,7 @@ function eslint() {
{ {
start: 'Running eslint...', start: 'Running eslint...',
succeed: 'ESLint Passed.', succeed: 'ESLint Passed.',
failed: 'ESLint failed!' failed: 'ESLint failed!',
} }
); );
} }
@ -51,7 +51,7 @@ function stylelint() {
{ {
start: 'Running stylelint...', start: 'Running stylelint...',
succeed: 'Stylelint Passed.', succeed: 'Stylelint Passed.',
failed: 'Stylelint failed!' failed: 'Stylelint failed!',
} }
); );
} }

View File

@ -8,11 +8,11 @@ const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
export async function release() { export async function release() {
await releaseIt({ await releaseIt({
plugins: { plugins: {
[PLUGIN_PATH]: {} [PLUGIN_PATH]: {},
}, },
git: { git: {
tagName: 'v${version}', tagName: 'v${version}',
commitMessage: 'chore: release ${version}' commitMessage: 'chore: release ${version}',
} },
}); });
} }

View File

@ -4,13 +4,13 @@ import {
existsSync, existsSync,
readdirSync, readdirSync,
readFileSync, readFileSync,
outputFileSync outputFileSync,
} from 'fs-extra'; } from 'fs-extra';
import { import {
SRC_DIR, SRC_DIR,
getVantConfig, getVantConfig,
ROOT_WEBPACK_CONFIG_FILE, ROOT_WEBPACK_CONFIG_FILE,
ROOT_POSTCSS_CONFIG_FILE ROOT_POSTCSS_CONFIG_FILE,
} from './constant'; } from './constant';
export const EXT_REGEXP = /\.\w+$/; export const EXT_REGEXP = /\.\w+$/;

View File

@ -25,7 +25,7 @@ export async function installDependencies() {
const manager = hasYarn() ? 'yarn' : 'npm'; const manager = hasYarn() ? 'yarn' : 'npm';
await execa(manager, ['install', '--prod=false'], { await execa(manager, ['install', '--prod=false'], {
stdio: 'inherit' stdio: 'inherit',
}); });
console.log(''); console.log('');

View File

@ -8,7 +8,7 @@ const cleanCss = new CleanCss();
export async function compileCss(source: string | Buffer) { export async function compileCss(source: string | Buffer) {
const config = await postcssrc({}, POSTCSS_CONFIG_FILE); const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
const { css } = await postcss(config.plugins as any).process(source, { const { css } = await postcss(config.plugins as any).process(source, {
from: undefined from: undefined,
}); });
return cleanCss.minify(css).styles; return cleanCss.minify(css).styles;

View File

@ -13,14 +13,14 @@ class TildeResolver extends FileManager {
const TildeResolverPlugin = { const TildeResolverPlugin = {
install(lessInstance: unknown, pluginManager: any) { install(lessInstance: unknown, pluginManager: any) {
pluginManager.addFileManager(new TildeResolver()); pluginManager.addFileManager(new TildeResolver());
} },
}; };
export async function compileLess(filePath: string) { export async function compileLess(filePath: string) {
const source = readFileSync(filePath, 'utf-8'); const source = readFileSync(filePath, 'utf-8');
const { css } = await render(source, { const { css } = await render(source, {
filename: filePath, filename: filePath,
plugins: [TildeResolverPlugin] plugins: [TildeResolverPlugin],
}); });
return css; return css;

View File

@ -57,7 +57,7 @@ function compileTemplate(template: string) {
const result = compileUtils.compileTemplate({ const result = compileUtils.compileTemplate({
compiler, compiler,
source: template, source: template,
isProduction: true isProduction: true,
} as any); } as any);
return result.code; return result.code;
@ -73,7 +73,7 @@ export function parseSfc(filePath: string) {
const descriptor = compileUtils.parse({ const descriptor = compileUtils.parse({
source, source,
compiler, compiler,
needMap: false needMap: false,
} as any); } as any);
return descriptor; return descriptor;

View File

@ -39,7 +39,7 @@ function watch() {
getPort( getPort(
{ {
port: config.devServer!.port port: config.devServer!.port,
}, },
(err, port) => { (err, port) => {
if (err) { if (err) {

View File

@ -11,7 +11,7 @@ import {
ES_DIR, ES_DIR,
SRC_DIR, SRC_DIR,
LIB_DIR, LIB_DIR,
STYPE_DEPS_JSON_FILE STYPE_DEPS_JSON_FILE,
} from '../common/constant'; } from '../common/constant';
function getDeps(component: string): string[] { function getDeps(component: string): string[] {
@ -41,12 +41,12 @@ function getRelativePath(component: string, style: string, ext: string) {
const OUTPUT_CONFIG = [ const OUTPUT_CONFIG = [
{ {
dir: ES_DIR, dir: ES_DIR,
template: (dep: string) => `import '${dep}';` template: (dep: string) => `import '${dep}';`,
}, },
{ {
dir: LIB_DIR, dir: LIB_DIR,
template: (dep: string) => `require('${dep}');` template: (dep: string) => `require('${dep}');`,
} },
]; ];
function genEntry(params: { function genEntry(params: {
@ -92,7 +92,7 @@ export function genComponentStyle(
baseFile, baseFile,
component, component,
filename: 'index.js', filename: 'index.js',
ext: '.css' ext: '.css',
}); });
if (CSS_LANG !== 'css') { if (CSS_LANG !== 'css') {
@ -100,7 +100,7 @@ export function genComponentStyle(
baseFile, baseFile,
component, component,
filename: CSS_LANG + '.js', filename: CSS_LANG + '.js',
ext: '.' + CSS_LANG ext: '.' + CSS_LANG,
}); });
} }
}); });

View File

@ -1,6 +1,11 @@
import { get } from 'lodash'; import { get } from 'lodash';
import { join } from 'path'; import { join } from 'path';
import { pascalize, getComponents, smartOutputFile, normalizePath } from '../common'; import {
pascalize,
getComponents,
smartOutputFile,
normalizePath,
} from '../common';
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant'; import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
type Options = { type Options = {

View File

@ -6,14 +6,14 @@ import {
removeExt, removeExt,
getVantConfig, getVantConfig,
smartOutputFile, smartOutputFile,
normalizePath normalizePath,
} from '../common'; } from '../common';
import { import {
SRC_DIR, SRC_DIR,
DOCS_DIR, DOCS_DIR,
getPackageJson, getPackageJson,
VANT_CONFIG_FILE, VANT_CONFIG_FILE,
SITE_DESKTOP_SHARED_FILE SITE_DESKTOP_SHARED_FILE,
} from '../common/constant'; } from '../common/constant';
type DocumentItem = { type DocumentItem = {
@ -52,7 +52,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
components.forEach(component => { components.forEach(component => {
docs.push({ docs.push({
name: formatName(component, lang), name: formatName(component, lang),
path: join(SRC_DIR, component, fileName) path: join(SRC_DIR, component, fileName),
}); });
}); });
}); });
@ -60,7 +60,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
components.forEach(component => { components.forEach(component => {
docs.push({ docs.push({
name: formatName(component), name: formatName(component),
path: join(SRC_DIR, component, 'README.md') path: join(SRC_DIR, component, 'README.md'),
}); });
}); });
} }
@ -69,7 +69,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
const pairs = parse(path).name.split('.'); const pairs = parse(path).name.split('.');
return { return {
name: formatName(pairs[0], pairs[1] || defaultLang), name: formatName(pairs[0], pairs[1] || defaultLang),
path path,
}; };
}); });

View File

@ -7,7 +7,7 @@ import {
decamelize, decamelize,
getVantConfig, getVantConfig,
smartOutputFile, smartOutputFile,
normalizePath normalizePath,
} from '../common'; } from '../common';
type DemoItem = { type DemoItem = {
@ -25,7 +25,10 @@ import './package-style';
function genImports(demos: DemoItem[]) { function genImports(demos: DemoItem[]) {
return demos return demos
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`) .map(
item =>
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
)
.join('\n'); .join('\n');
} }
@ -73,7 +76,7 @@ function genCode(components: string[]) {
.map(component => ({ .map(component => ({
component, component,
name: pascalize(component), name: pascalize(component),
path: join(SRC_DIR, component, 'demo/index.vue') path: join(SRC_DIR, component, 'demo/index.vue'),
})) }))
.filter(item => existsSync(item.path)); .filter(item => existsSync(item.path));

View File

@ -14,7 +14,7 @@ export function genVeturConfig() {
path: SRC_DIR, path: SRC_DIR,
test: /zh-CN\.md/, test: /zh-CN\.md/,
outputDir: join(ROOT, 'vetur'), outputDir: join(ROOT, 'vetur'),
...options ...options,
}); });
} }
} }

View File

@ -15,10 +15,10 @@ export async function genSiteEntry() {
genStyleDepsMap() genStyleDepsMap()
.then(() => { .then(() => {
genPackageEntry({ genPackageEntry({
outputPath: PACKAGE_ENTRY_FILE outputPath: PACKAGE_ENTRY_FILE,
}); });
genPacakgeStyle({ genPacakgeStyle({
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`) outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`),
}); });
genSiteMobileShared(); genSiteMobileShared();
genSiteDesktopShared(); genSiteDesktopShared();

View File

@ -15,38 +15,38 @@ module.exports = function(api?: ConfigAPI) {
'@babel/preset-env', '@babel/preset-env',
{ {
loose: true, loose: true,
modules: useESModules ? false : 'commonjs' modules: useESModules ? false : 'commonjs',
} },
], ],
[ [
'@vue/babel-preset-jsx', '@vue/babel-preset-jsx',
{ {
functional: false functional: false,
} },
], ],
'@babel/preset-typescript' '@babel/preset-typescript',
], ],
plugins: [ plugins: [
[ [
'@babel/plugin-transform-runtime', '@babel/plugin-transform-runtime',
{ {
corejs: false, corejs: false,
useESModules useESModules,
} },
], ],
[ [
'import', 'import',
{ {
libraryName: 'vant', libraryName: 'vant',
libraryDirectory: useESModules ? 'es' : 'lib', libraryDirectory: useESModules ? 'es' : 'lib',
style: true style: true,
}, },
'vant' 'vant',
], ],
'@babel/plugin-transform-object-assign', '@babel/plugin-transform-object-assign',
'@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator' '@babel/plugin-proposal-nullish-coalescing-operator',
] ],
}; };
}; };

View File

@ -4,26 +4,26 @@ import {
ROOT, ROOT,
JEST_SETUP_FILE, JEST_SETUP_FILE,
JEST_FILE_MOCK_FILE, JEST_FILE_MOCK_FILE,
JEST_STYLE_MOCK_FILE JEST_STYLE_MOCK_FILE,
} from '../common/constant'; } from '../common/constant';
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
moduleNameMapper: { moduleNameMapper: {
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE, '\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE,
}, },
setupFilesAfterEnv: [JEST_SETUP_FILE], setupFilesAfterEnv: [JEST_SETUP_FILE],
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'], moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
transform: { transform: {
'\\.(vue)$': 'vue-jest', '\\.(vue)$': 'vue-jest',
'\\.(js|jsx|ts|tsx)$': 'babel-jest' '\\.(js|jsx|ts|tsx)$': 'babel-jest',
}, },
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'], transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
snapshotSerializers: ['jest-serializer-vue'], snapshotSerializers: ['jest-serializer-vue'],
collectCoverage: true, collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'], collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'],
coverageReporters: ['html', 'lcov', 'text-summary'], coverageReporters: ['html', 'lcov', 'text-summary'],
coverageDirectory: './test/coverage' coverageDirectory: './test/coverage',
}; };
function readRootConfig() { function readRootConfig() {
@ -38,5 +38,5 @@ function readRootConfig() {
module.exports = { module.exports = {
...DEFAULT_CONFIG, ...DEFAULT_CONFIG,
...readRootConfig() ...readRootConfig(),
}; };

View File

@ -7,20 +7,20 @@ type PostcssConfig = object & {
function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) { function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) {
const plugins = { const plugins = {
...config1.plugins, ...config1.plugins,
...config2.plugins ...config2.plugins,
}; };
return { return {
...config1, ...config1,
...config2, ...config2,
plugins plugins,
}; };
} }
const DEFAULT_CONFIG = { const DEFAULT_CONFIG = {
plugins: { plugins: {
autoprefixer: {} autoprefixer: {},
} },
}; };
module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig()); module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig());

View File

@ -6,14 +6,14 @@ import {
CACHE_DIR, CACHE_DIR,
STYLE_EXTS, STYLE_EXTS,
SCRIPT_EXTS, SCRIPT_EXTS,
POSTCSS_CONFIG_FILE POSTCSS_CONFIG_FILE,
} from '../common/constant'; } from '../common/constant';
const CACHE_LOADER = { const CACHE_LOADER = {
loader: 'cache-loader', loader: 'cache-loader',
options: { options: {
cacheDirectory: CACHE_DIR cacheDirectory: CACHE_DIR,
} },
}; };
const CSS_LOADERS = [ const CSS_LOADERS = [
@ -23,16 +23,16 @@ const CSS_LOADERS = [
loader: 'postcss-loader', loader: 'postcss-loader',
options: { options: {
config: { config: {
path: POSTCSS_CONFIG_FILE path: POSTCSS_CONFIG_FILE,
} },
} },
} },
]; ];
export const baseConfig = { export const baseConfig = {
mode: 'development', mode: 'development',
resolve: { resolve: {
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS] extensions: [...SCRIPT_EXTS, ...STYLE_EXTS],
}, },
module: { module: {
rules: [ rules: [
@ -44,26 +44,26 @@ export const baseConfig = {
loader: 'vue-loader', loader: 'vue-loader',
options: { options: {
compilerOptions: { compilerOptions: {
preserveWhitespace: false preserveWhitespace: false,
} },
} },
} },
] ],
}, },
{ {
test: /\.(js|ts|jsx|tsx)$/, test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules\/(?!(@vant\/cli))/, exclude: /node_modules\/(?!(@vant\/cli))/,
use: [CACHE_LOADER, 'babel-loader'] use: [CACHE_LOADER, 'babel-loader'],
}, },
{ {
test: /\.css$/, test: /\.css$/,
sideEffects: true, sideEffects: true,
use: CSS_LOADERS use: CSS_LOADERS,
}, },
{ {
test: /\.less$/, test: /\.less$/,
sideEffects: true, sideEffects: true,
use: [...CSS_LOADERS, 'less-loader'] use: [...CSS_LOADERS, 'less-loader'],
}, },
{ {
test: /\.scss$/, test: /\.scss$/,
@ -73,22 +73,22 @@ export const baseConfig = {
{ {
loader: 'sass-loader', loader: 'sass-loader',
options: { options: {
implementation: sass implementation: sass,
} },
} },
] ],
}, },
{ {
test: /\.md$/, test: /\.md$/,
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'] use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'],
} },
] ],
}, },
plugins: [ plugins: [
new VueLoaderPlugin(), new VueLoaderPlugin(),
new FriendlyErrorsPlugin({ new FriendlyErrorsPlugin({
clearConsole: false, clearConsole: false,
logLevel: 'WARNING' logLevel: 'WARNING',
}) }),
] ],
}; };

View File

@ -14,7 +14,7 @@ export function getPackageConfig(isMinify: boolean) {
{ {
mode: 'production', mode: 'production',
entry: { entry: {
[name]: join(ES_DIR, 'index.js') [name]: join(ES_DIR, 'index.js'),
}, },
stats: 'none', stats: 'none',
output: { output: {
@ -24,20 +24,20 @@ export function getPackageConfig(isMinify: boolean) {
filename: isMinify ? '[name].min.js' : '[name].js', filename: isMinify ? '[name].min.js' : '[name].js',
umdNamedDefine: true, umdNamedDefine: true,
// https://github.com/webpack/webpack/issues/6522 // https://github.com/webpack/webpack/issues/6522
globalObject: "typeof self !== 'undefined' ? self : this" globalObject: "typeof self !== 'undefined' ? self : this",
}, },
externals: { externals: {
vue: { vue: {
root: 'Vue', root: 'Vue',
commonjs: 'vue', commonjs: 'vue',
commonjs2: 'vue', commonjs2: 'vue',
amd: 'vue' amd: 'vue',
} },
}, },
performance: false, performance: false,
optimization: { optimization: {
minimize: isMinify minimize: isMinify,
} },
}, },
getWebpackConfig() getWebpackConfig()
); );

View File

@ -10,7 +10,7 @@ import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
import { import {
GREEN, GREEN,
SITE_MODILE_SHARED_FILE, SITE_MODILE_SHARED_FILE,
SITE_DESKTOP_SHARED_FILE SITE_DESKTOP_SHARED_FILE,
} from '../common/constant'; } from '../common/constant';
export function getSiteDevBaseConfig() { export function getSiteDevBaseConfig() {
@ -43,7 +43,7 @@ export function getSiteDevBaseConfig() {
return merge(baseConfig as any, { return merge(baseConfig as any, {
entry: { entry: {
'site-desktop': [join(__dirname, '../../site/desktop/main.js')], 'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
'site-mobile': [join(__dirname, '../../site/mobile/main.js')] 'site-mobile': [join(__dirname, '../../site/mobile/main.js')],
}, },
devServer: { devServer: {
port: 8080, port: 8080,
@ -51,16 +51,16 @@ export function getSiteDevBaseConfig() {
host: '0.0.0.0', host: '0.0.0.0',
stats: 'errors-only', stats: 'errors-only',
publicPath: '/', publicPath: '/',
disableHostCheck: true disableHostCheck: true,
}, },
resolve: { resolve: {
alias: { alias: {
'site-mobile-shared': SITE_MODILE_SHARED_FILE, 'site-mobile-shared': SITE_MODILE_SHARED_FILE,
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE 'site-desktop-shared': SITE_DESKTOP_SHARED_FILE,
} },
}, },
output: { output: {
chunkFilename: '[name].js' chunkFilename: '[name].js',
}, },
optimization: { optimization: {
splitChunks: { splitChunks: {
@ -69,15 +69,15 @@ export function getSiteDevBaseConfig() {
chunks: 'all', chunks: 'all',
minChunks: 2, minChunks: 2,
minSize: 0, minSize: 0,
name: 'chunks' name: 'chunks',
} },
} },
} },
}, },
plugins: [ plugins: [
new WebpackBar({ new WebpackBar({
name: 'Vant Cli', name: 'Vant Cli',
color: GREEN color: GREEN,
}), }),
new VantCliSitePlugin(), new VantCliSitePlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
@ -87,7 +87,7 @@ export function getSiteDevBaseConfig() {
chunks: ['chunks', 'site-desktop'], chunks: ['chunks', 'site-desktop'],
template: join(__dirname, '../../site/desktop/index.html'), template: join(__dirname, '../../site/desktop/index.html'),
filename: 'index.html', filename: 'index.html',
baiduAnalytics baiduAnalytics,
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title, title,
@ -96,9 +96,9 @@ export function getSiteDevBaseConfig() {
chunks: ['chunks', 'site-mobile'], chunks: ['chunks', 'site-mobile'],
template: join(__dirname, '../../site/mobile/index.html'), template: join(__dirname, '../../site/mobile/index.html'),
filename: 'mobile.html', filename: 'mobile.html',
baiduAnalytics baiduAnalytics,
}) }),
] ],
}); });
} }

View File

@ -18,8 +18,8 @@ export function getSitePrdConfig() {
publicPath, publicPath,
path: outputDir, path: outputDir,
filename: '[name].[hash:8].js', filename: '[name].[hash:8].js',
chunkFilename: 'async_[name].[chunkhash:8].js' chunkFilename: 'async_[name].[chunkhash:8].js',
} },
}, },
getWebpackConfig() getWebpackConfig()
); );

View File

@ -1466,13 +1466,6 @@
resolved "https://registry.npm.taobao.org/@types/source-list-map/download/@types/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" resolved "https://registry.npm.taobao.org/@types/source-list-map/download/@types/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
integrity sha1-AHiDYGP/rxdBI0m7o2QIfgrALsk= integrity sha1-AHiDYGP/rxdBI0m7o2QIfgrALsk=
"@types/source-map@^0.5.7":
version "0.5.7"
resolved "https://registry.npm.taobao.org/@types/source-map/download/@types/source-map-0.5.7.tgz#165eeb583c1ef00196fe4ef4da5d7832b03b275b"
integrity sha1-Fl7rWDwe8AGW/k702l14MrA7J1s=
dependencies:
source-map "*"
"@types/stack-utils@^1.0.1": "@types/stack-utils@^1.0.1":
version "1.0.1" version "1.0.1"
resolved "https://registry.npm.taobao.org/@types/stack-utils/download/@types/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" resolved "https://registry.npm.taobao.org/@types/stack-utils/download/@types/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
@ -1562,59 +1555,59 @@
dependencies: dependencies:
"@types/yargs-parser" "*" "@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@^2.12.0": "@typescript-eslint/eslint-plugin@^2.16.0":
version "2.12.0" version "2.16.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.12.0.tgz#0da7cbca7b24f4c6919e9eb31c704bfb126f90ad" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.16.0.tgz#bf339b7db824c7cc3fd1ebedbc88dd17016471af"
integrity sha512-1t4r9rpLuEwl3hgt90jY18wJHSyb0E3orVL3DaqwmpiSDHmHiSspVsvsFF78BJ/3NNG3qmeso836jpuBWYziAA== integrity sha512-TKWbeFAKRPrvKiR9GNxErQ8sELKqg1ZvXi6uho07mcKShBnCnqNpDQWP01FEvWKf0bxM2g7uQEI5MNjSNqvUpQ==
dependencies: dependencies:
"@typescript-eslint/experimental-utils" "2.12.0" "@typescript-eslint/experimental-utils" "2.16.0"
eslint-utils "^1.4.3" eslint-utils "^1.4.3"
functional-red-black-tree "^1.0.1" functional-red-black-tree "^1.0.1"
regexpp "^3.0.0" regexpp "^3.0.0"
tsutils "^3.17.1" tsutils "^3.17.1"
"@typescript-eslint/experimental-utils@2.12.0": "@typescript-eslint/experimental-utils@2.16.0":
version "2.12.0" version "2.16.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.12.0.tgz#e0a76ffb6293e058748408a191921e453c31d40d" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.16.0.tgz#bba65685728c532e0ddc811a0376e8d38e671f77"
integrity sha512-jv4gYpw5N5BrWF3ntROvCuLe1IjRenLy5+U57J24NbPGwZFAjhnM45qpq0nDH1y/AZMb3Br25YiNVwyPbz6RkA== integrity sha512-bXTmAztXpqxliDKZgvWkl+5dHeRN+jqXVZ16peKKFzSXVzT6mz8kgBpHiVzEKO2NZ8OCU7dG61K9sRS/SkUUFQ==
dependencies: dependencies:
"@types/json-schema" "^7.0.3" "@types/json-schema" "^7.0.3"
"@typescript-eslint/typescript-estree" "2.12.0" "@typescript-eslint/typescript-estree" "2.16.0"
eslint-scope "^5.0.0" eslint-scope "^5.0.0"
"@typescript-eslint/parser@^2.12.0": "@typescript-eslint/parser@^2.16.0":
version "2.12.0" version "2.16.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.12.0.tgz#393f1604943a4ca570bb1a45bc8834e9b9158884" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.16.0.tgz#d0c0135a8fdb915f670802ddd7c1ba457c1b4f9d"
integrity sha512-lPdkwpdzxEfjI8TyTzZqPatkrswLSVu4bqUgnB03fHSOwpC7KSerPgJRgIAf11UGNf7HKjJV6oaPZI4AghLU6g== integrity sha512-+w8dMaYETM9v6il1yYYkApMSiwgnqXWJbXrA94LAWN603vXHACsZTirJduyeBOJjA9wT6xuXe5zZ1iCUzoxCfw==
dependencies: dependencies:
"@types/eslint-visitor-keys" "^1.0.0" "@types/eslint-visitor-keys" "^1.0.0"
"@typescript-eslint/experimental-utils" "2.12.0" "@typescript-eslint/experimental-utils" "2.16.0"
"@typescript-eslint/typescript-estree" "2.12.0" "@typescript-eslint/typescript-estree" "2.16.0"
eslint-visitor-keys "^1.1.0" eslint-visitor-keys "^1.1.0"
"@typescript-eslint/typescript-estree@2.12.0": "@typescript-eslint/typescript-estree@2.16.0":
version "2.12.0" version "2.16.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.12.0.tgz#bd9e547ccffd17dfab0c3ab0947c80c8e2eb914c" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.16.0.tgz#b444943a76c716ed32abd08cbe96172d2ca0ab75"
integrity sha512-rGehVfjHEn8Frh9UW02ZZIfJs6SIIxIu/K1bbci8rFfDE/1lQ8krIJy5OXOV3DVnNdDPtoiPOdEANkLMrwXbiQ== integrity sha512-hyrCYjFHISos68Bk5KjUAXw0pP/455qq9nxqB1KkT67Pxjcfw+r6Yhcmqnp8etFL45UexCHUMrADHH7dI/m2WQ==
dependencies: dependencies:
debug "^4.1.1" debug "^4.1.1"
eslint-visitor-keys "^1.1.0" eslint-visitor-keys "^1.1.0"
glob "^7.1.6" glob "^7.1.6"
is-glob "^4.0.1" is-glob "^4.0.1"
lodash.unescape "4.0.1" lodash "^4.17.15"
semver "^6.3.0" semver "^6.3.0"
tsutils "^3.17.1" tsutils "^3.17.1"
"@vant/eslint-config@^1.5.1": "@vant/eslint-config@^2.0.0":
version "1.5.1" version "2.0.0"
resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.5.1.tgz#cfa4418b0b43ca0afb7dbda6973b2b1450306fb2" resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-2.0.0.tgz#cbfc1daaa42c5ffcf9fa4341d867149737986967"
integrity sha512-jGN4GJw+MYeXGH9XsYeaWJMpD8TwS1fx4qw4kGXoud8VM6tMdUToxodzJRERoHlDgnpxsqwd4bOf1aztoVuuHg== integrity sha512-W6v4gNieMTGOGWSJVuSSdYjHy3giELbJibFlCMuCGK8VE8MFMSwz2M/riG/NxEOoKx51J1MVH9rFy3lvWuMH6g==
dependencies: dependencies:
"@typescript-eslint/eslint-plugin" "^2.12.0" "@typescript-eslint/eslint-plugin" "^2.16.0"
"@typescript-eslint/parser" "^2.12.0" "@typescript-eslint/parser" "^2.16.0"
eslint-config-airbnb-base "^14.0.0" eslint-config-airbnb-base "^14.0.0"
eslint-plugin-import "^2.19.1" eslint-plugin-import "^2.20.0"
eslint-plugin-vue "^6.0.1" eslint-plugin-vue "^6.1.2"
"@vant/markdown-loader@^2.3.0": "@vant/markdown-loader@^2.3.0":
version "2.3.0" version "2.3.0"
@ -1954,7 +1947,7 @@ acorn-globals@^4.1.0:
acorn "^6.0.1" acorn "^6.0.1"
acorn-walk "^6.0.1" acorn-walk "^6.0.1"
acorn-jsx@^5.0.0, acorn-jsx@^5.1.0: acorn-jsx@^5.1.0:
version "5.1.0" version "5.1.0"
resolved "https://registry.npm.taobao.org/acorn-jsx/download/acorn-jsx-5.1.0.tgz?cache=0&sync_timestamp=1570991459312&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Facorn-jsx%2Fdownload%2Facorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384" resolved "https://registry.npm.taobao.org/acorn-jsx/download/acorn-jsx-5.1.0.tgz?cache=0&sync_timestamp=1570991459312&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Facorn-jsx%2Fdownload%2Facorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384"
integrity sha1-KUrbcbVzmLBoABXwo4xWPuHbU4Q= integrity sha1-KUrbcbVzmLBoABXwo4xWPuHbU4Q=
@ -1974,11 +1967,6 @@ acorn@^6.0.1, acorn@^6.2.1:
resolved "https://registry.npm.taobao.org/acorn/download/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e" resolved "https://registry.npm.taobao.org/acorn/download/acorn-6.3.0.tgz#0087509119ffa4fc0a0041d1e93a417e68cb856e"
integrity sha1-AIdQkRn/pPwKAEHR6TpBfmjLhW4= integrity sha1-AIdQkRn/pPwKAEHR6TpBfmjLhW4=
acorn@^6.0.7:
version "6.4.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.0.tgz#b659d2ffbafa24baf5db1cdbb2c94a983ecd2784"
integrity sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==
acorn@^7.1.0: acorn@^7.1.0:
version "7.1.0" version "7.1.0"
resolved "https://registry.npm.taobao.org/acorn/download/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c" resolved "https://registry.npm.taobao.org/acorn/download/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c"
@ -4381,10 +4369,10 @@ eslint-module-utils@^2.4.1:
debug "^2.6.9" debug "^2.6.9"
pkg-dir "^2.0.0" pkg-dir "^2.0.0"
eslint-plugin-import@^2.19.1: eslint-plugin-import@^2.20.0:
version "2.19.1" version "2.20.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.19.1.tgz#5654e10b7839d064dd0d46cd1b88ec2133a11448" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.20.0.tgz#d749a7263fb6c29980def8e960d380a6aa6aecaa"
integrity sha512-x68131aKoCZlCae7rDXKSAQmbT5DQuManyXo2sK6fJJ0aK5CWAkv6A6HJZGgqC8IhjQxYPgo6/IY4Oz8AFsbBw== integrity sha512-NK42oA0mUc8Ngn4kONOPsPB1XhbUvNHqF+g307dPV28aknPoiNnKLFd9em4nkswwepdF5ouieqv5Th/63U7YJQ==
dependencies: dependencies:
array-includes "^3.0.3" array-includes "^3.0.3"
array.prototype.flat "^1.2.1" array.prototype.flat "^1.2.1"
@ -4399,14 +4387,15 @@ eslint-plugin-import@^2.19.1:
read-pkg-up "^2.0.0" read-pkg-up "^2.0.0"
resolve "^1.12.0" resolve "^1.12.0"
eslint-plugin-vue@^6.0.1: eslint-plugin-vue@^6.1.2:
version "6.0.1" version "6.1.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-6.0.1.tgz#166d3eb24cf290f3ff24d44fe9fca496f3924fc2" resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-6.1.2.tgz#4b05c28c83c0ec912669b64dbd998bb8bf692ef6"
integrity sha512-5tgFPcxGDKjfVB/6Yi56bKiWxygUibfZmzSh26Np3kuwAk/lfaGbVld+Yt+MPgD84ppvcachtiL4/winsXLjXA== integrity sha512-M75oAB+2a/LNkLKRbeEaS07EjzjIUaV7/hYoHAfRFeeF8ZMmCbahUn8nQLsLP85mkar24+zDU3QW2iT1JRsACw==
dependencies: dependencies:
vue-eslint-parser "^6.0.5" semver "^5.6.0"
vue-eslint-parser "^7.0.0"
eslint-scope@^4.0.0, eslint-scope@^4.0.3: eslint-scope@^4.0.3:
version "4.0.3" version "4.0.3"
resolved "https://registry.npm.taobao.org/eslint-scope/download/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" resolved "https://registry.npm.taobao.org/eslint-scope/download/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
integrity sha1-ygODMxD2iJoyZHgaqC5j65z+eEg= integrity sha1-ygODMxD2iJoyZHgaqC5j65z+eEg=
@ -4429,7 +4418,7 @@ eslint-utils@^1.4.3:
dependencies: dependencies:
eslint-visitor-keys "^1.1.0" eslint-visitor-keys "^1.1.0"
eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: eslint-visitor-keys@^1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.npm.taobao.org/eslint-visitor-keys/download/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" resolved "https://registry.npm.taobao.org/eslint-visitor-keys/download/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
integrity sha1-4qgs6oT/JGrW+1f5veW0ZiFFnsI= integrity sha1-4qgs6oT/JGrW+1f5veW0ZiFFnsI=
@ -4477,15 +4466,6 @@ eslint@^6.8.0:
text-table "^0.2.0" text-table "^0.2.0"
v8-compile-cache "^2.0.3" v8-compile-cache "^2.0.3"
espree@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a"
integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==
dependencies:
acorn "^6.0.7"
acorn-jsx "^5.0.0"
eslint-visitor-keys "^1.0.0"
espree@^6.1.2: espree@^6.1.2:
version "6.1.2" version "6.1.2"
resolved "https://registry.npm.taobao.org/espree/download/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d" resolved "https://registry.npm.taobao.org/espree/download/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d"
@ -7263,11 +7243,6 @@ lodash.templatesettings@^4.0.0:
dependencies: dependencies:
lodash._reinterpolate "^3.0.0" lodash._reinterpolate "^3.0.0"
lodash.unescape@4.0.1:
version "4.0.1"
resolved "https://registry.npm.taobao.org/lodash.unescape/download/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=
lodash.uniq@^4.5.0: lodash.uniq@^4.5.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.npm.taobao.org/lodash.uniq/download/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" resolved "https://registry.npm.taobao.org/lodash.uniq/download/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
@ -10150,11 +10125,6 @@ source-map-url@^0.4.0:
resolved "https://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" resolved "https://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=
source-map@*:
version "0.7.3"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha1-UwL4FpAxc1ImVECS5kmB91F1A4M=
source-map@^0.5.0, source-map@^0.5.6: source-map@^0.5.0, source-map@^0.5.6:
version "0.5.7" version "0.5.7"
resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
@ -11432,17 +11402,17 @@ vm-browserify@^1.0.1:
resolved "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz?cache=0&sync_timestamp=1572870772154&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvm-browserify%2Fdownload%2Fvm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" resolved "https://registry.npm.taobao.org/vm-browserify/download/vm-browserify-1.1.2.tgz?cache=0&sync_timestamp=1572870772154&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvm-browserify%2Fdownload%2Fvm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha1-eGQcSIuObKkadfUR56OzKobl3aA= integrity sha1-eGQcSIuObKkadfUR56OzKobl3aA=
vue-eslint-parser@^6.0.5: vue-eslint-parser@^7.0.0:
version "6.0.5" version "7.0.0"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-6.0.5.tgz#c1c067c2755748e28f3872cd42e8c1c4c1a8059f" resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.0.0.tgz#a4ed2669f87179dedd06afdd8736acbb3a3864d6"
integrity sha512-Bvjlx7rH1Ulvus56KHeLXOjEi3JMOYTa1GAqZr9lBQhd8weK8mV7U7V2l85yokBZEWHJQjLn6X3nosY8TzkOKg== integrity sha512-yR0dLxsTT7JfD2YQo9BhnQ6bUTLsZouuzt9SKRP7XNaZJV459gvlsJo4vT2nhZ/2dH9j3c53bIx9dnqU2prM9g==
dependencies: dependencies:
debug "^4.1.1" debug "^4.1.1"
eslint-scope "^4.0.0" eslint-scope "^5.0.0"
eslint-visitor-keys "^1.0.0" eslint-visitor-keys "^1.1.0"
espree "^5.0.0" espree "^6.1.2"
esquery "^1.0.1" esquery "^1.0.1"
lodash "^4.17.11" lodash "^4.17.15"
vue-hot-reload-api@^2.3.0: vue-hot-reload-api@^2.3.0:
version "2.3.4" version "2.3.4"